You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
* renamed: spec/unit/login.spec.js -> spec/unit/login.spec.ts * type test client * renamed: spec/unit/interactive-auth.spec.js -> spec/unit/interactive-auth.spec.ts * fix ts issues in interactive-auth.spec * renamed: spec/unit/filter.spec.js -> spec/unit/filter.spec.ts * fix ts in filter.spec * renamed: spec/unit/event.spec.js -> spec/unit/event.spec.ts * ts in event.spec * renamed: spec/unit/pushprocessor.spec.js -> spec/unit/pushprocessor.spec.ts * fix ts in pushprocessor.spec * fix ts in realtime-callbacks.spec * renamed: spec/unit/content-repo.spec.js -> spec/unit/content-repo.spec.ts * fix signature for getHttpUriForMxc * pr fixes
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { Filter, IFilterDefinition } from "../../src/filter";
|
|
|
|
describe("Filter", function() {
|
|
const filterId = "f1lt3ring15g00d4ursoul";
|
|
const userId = "@sir_arthur_david:humming.tiger";
|
|
let filter: 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" as IFilterDefinition['event_format'],
|
|
};
|
|
filter.setDefinition(definition);
|
|
expect(filter.getDefinition()).toEqual(definition);
|
|
});
|
|
});
|
|
});
|