1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-09-10 17:31:53 +03:00

check power levels without relying on membership

as this might not be known for the syncing user.
instead, add a method to room which always knows the syncing user's membership
This commit is contained in:
Bruno Windels
2018-09-04 15:30:16 +02:00
parent 3d98e324b5
commit 8b00083bca
5 changed files with 52 additions and 38 deletions

View File

@@ -1400,7 +1400,7 @@ describe("Room", function() {
describe("getMyMembership", function() {
it("should return synced membership if membership isn't available yet",
async function() {
function() {
const room = new Room(roomId, null, userA);
room.setSyncedMembership("invite");
expect(room.getMyMembership()).toEqual("invite");
@@ -1434,4 +1434,17 @@ describe("Room", function() {
expect(room.guessDMUserId()).toEqual(userA);
});
});
describe("maySendMessage", function() {
it("should return false if synced membership not join",
function() {
const room = new Room(roomId, null, userA);
room.setSyncedMembership("invite");
expect(room.maySendMessage()).toEqual(false);
room.setSyncedMembership("leave");
expect(room.maySendMessage()).toEqual(false);
room.setSyncedMembership("join");
expect(room.maySendMessage()).toEqual(true);
});
});
});