diff --git a/spec/unit/room.spec.js b/spec/unit/room.spec.js index b98559ecf..a355f95fa 100644 --- a/spec/unit/room.spec.js +++ b/spec/unit/room.spec.js @@ -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); + }); + }); });