element-web/test/createRoom-test.js

30 lines
946 B
JavaScript
Raw Normal View History

import { canEncryptToAllUsers } from '../src/createRoom';
describe("canEncryptToAllUsers", () => {
const trueUser = {
"@goodUser:localhost": {
"DEV1": {},
"DEV2": {},
},
};
const falseUser = {
"@badUser:localhost": {},
};
it("returns true if all devices have crypto", async () => {
const client = {
downloadKeys: async function(userIds) { return trueUser; },
};
const response = await canEncryptToAllUsers(client, ["@goodUser:localhost"]);
expect(response).toBe(true);
});
it("returns false if not all users have crypto", async () => {
const client = {
2021-06-29 12:11:58 +00:00
downloadKeys: async function(userIds) { return { ...trueUser, ...falseUser }; },
};
const response = await canEncryptToAllUsers(client, ["@goodUser:localhost", "@badUser:localhost"]);
expect(response).toBe(false);
});
});