You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-09 10:22:46 +03:00
Now that we're pointing at `src/` for tests, we can stop trying to load source maps from random places. With this dependency used, source maps are off by a few lines.
47 lines
1.4 KiB
JavaScript
47 lines
1.4 KiB
JavaScript
import {Filter} from "../../src/filter";
|
|
|
|
describe("Filter", function() {
|
|
const filterId = "f1lt3ring15g00d4ursoul";
|
|
const userId = "@sir_arthur_david:humming.tiger";
|
|
let filter;
|
|
|
|
beforeEach(function() {
|
|
filter = new Filter(userId);
|
|
});
|
|
|
|
describe("fromJson", function() {
|
|
it("create a new Filter from the provided values", function() {
|
|
const definition = {
|
|
event_fields: ["type", "content"],
|
|
};
|
|
const f = Filter.fromJson(userId, filterId, definition);
|
|
expect(f.getDefinition()).toEqual(definition);
|
|
expect(f.userId).toEqual(userId);
|
|
expect(f.filterId).toEqual(filterId);
|
|
});
|
|
});
|
|
|
|
describe("setTimelineLimit", function() {
|
|
it("should set room.timeline.limit of the filter definition", function() {
|
|
filter.setTimelineLimit(10);
|
|
expect(filter.getDefinition()).toEqual({
|
|
room: {
|
|
timeline: {
|
|
limit: 10,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("setDefinition/getDefinition", function() {
|
|
it("should set and get the filter body", function() {
|
|
const definition = {
|
|
event_format: "client",
|
|
};
|
|
filter.setDefinition(definition);
|
|
expect(filter.getDefinition()).toEqual(definition);
|
|
});
|
|
});
|
|
});
|