1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-07-31 15:24:23 +03:00

some tests for room.guessDMUserId()

This commit is contained in:
Bruno Windels
2018-09-04 13:01:45 +02:00
parent f0d3d0d74e
commit a3567f0918

View File

@ -1411,4 +1411,27 @@ describe("Room", function() {
expect(room.getMyMembership()).toEqual("join");
});
});
describe("guessDMUserId", function() {
it("should return first hero id",
async function() {
const room = new Room(roomId, null, userA);
room.setSummary({'m.heroes': [userB]});
expect(room.guessDMUserId()).toEqual(userB);
});
it("should return first member that isn't self",
async function() {
const room = new Room(roomId, null, userA);
room.addLiveEvents([utils.mkMembership({
user: userB, mship: "join",
room: roomId, event: true,
})]);
expect(room.guessDMUserId()).toEqual(userB);
});
it("should return self if only member present",
async function() {
const room = new Room(roomId, null, userA);
expect(room.guessDMUserId()).toEqual(userA);
});
});
});