mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-14 11:05:32 -04:00
32 lines
1015 B
JavaScript
32 lines
1015 B
JavaScript
const { DeviceLists, UserId } = require("../");
|
|
|
|
describe(DeviceLists.name, () => {
|
|
test("can be empty", () => {
|
|
const empty = new DeviceLists();
|
|
|
|
expect(empty.isEmpty()).toStrictEqual(true);
|
|
expect(empty.changed).toHaveLength(0);
|
|
expect(empty.left).toHaveLength(0);
|
|
});
|
|
|
|
test("can be coerced empty", () => {
|
|
const empty = new DeviceLists([], []);
|
|
|
|
expect(empty.isEmpty()).toStrictEqual(true);
|
|
expect(empty.changed).toHaveLength(0);
|
|
expect(empty.left).toHaveLength(0);
|
|
});
|
|
|
|
test("returns the correct `changed` and `left`", () => {
|
|
const list = new DeviceLists([new UserId("@foo:bar.org")], [new UserId("@baz:qux.org")]);
|
|
|
|
expect(list.isEmpty()).toStrictEqual(false);
|
|
|
|
expect(list.changed).toHaveLength(1);
|
|
expect(list.changed[0].toString()).toStrictEqual("@foo:bar.org");
|
|
|
|
expect(list.left).toHaveLength(1);
|
|
expect(list.left[0].toString()).toStrictEqual("@baz:qux.org");
|
|
});
|
|
});
|