From 476b81fc1eba3d7dc0db7ae4a7770c6e9485842c Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Thu, 21 Feb 2019 17:58:23 +0100 Subject: [PATCH] add test for membership change --- test/matrix-to-test.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/matrix-to-test.js b/test/matrix-to-test.js index 9ae37463bc..2434ac48f0 100644 --- a/test/matrix-to-test.js +++ b/test/matrix-to-test.js @@ -104,6 +104,33 @@ describe('matrix-to', function() { // we don't check the 2nd and 3rd servers because that is done by the next test }); + it('should change candidate server when highest power level user leaves the room', function() { + const member95 = { + userId: "@alice:pl_95", + powerLevel: 95, + }; + const room = mockRoom(null, [ + { + userId: "@alice:pl_50", + powerLevel: 50, + }, + { + userId: "@alice:pl_75", + powerLevel: 75, + }, + member95, + ]); + const creator = new RoomPermaLinkCreator(room); + creator.load(); + expect(creator._serverCandidates[0]).toBe("pl_95"); + member95.membership = "left"; + creator.onMembership({}, member95, "join"); + expect(creator._serverCandidates[0]).toBe("pl_75"); + member95.membership = "join"; + creator.onMembership({}, member95, "left"); + expect(creator._serverCandidates[0]).toBe("pl_95"); + }); + it('should pick candidate servers based on user population', function() { const room = mockRoom(null, [ {