1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Merge branch 'develop' into dbkr/new_unread_count_format

This commit is contained in:
David Baker
2016-01-20 17:25:54 +00:00
2 changed files with 16 additions and 26 deletions

View File

@@ -743,12 +743,12 @@ function calculateRoomName(room, userId, ignoreRoomNameEvent) {
} }
} }
else { else {
return userId; // XXX: why userId and not displayname or something? return memberList[0].name;
} }
} }
else { else {
// there really isn't anyone in this room... // there really isn't anyone in this room...
return "?"; return "Empty room";
} }
} }
else if (members.length === 1) { else if (members.length === 1) {

View File

@@ -328,50 +328,40 @@ describe("Room", function() {
it("should return true for a matching userId and membership", it("should return true for a matching userId and membership",
function() { function() {
room.currentState.getMembers.andCallFake(function() { room.currentState.members = {
return [ "@alice:bar": { userId: "@alice:bar", membership: "join" },
{ userId: "@alice:bar", membership: "join" }, "@bob:bar": { userId: "@bob:bar", membership: "invite" }
{ userId: "@bob:bar", membership: "invite" } };
];
});
expect(room.hasMembershipState("@bob:bar", "invite")).toBe(true); expect(room.hasMembershipState("@bob:bar", "invite")).toBe(true);
}); });
it("should return false if match membership but no match userId", it("should return false if match membership but no match userId",
function() { function() {
room.currentState.getMembers.andCallFake(function() { room.currentState.members = {
return [ "@alice:bar": { userId: "@alice:bar", membership: "join" }
{ userId: "@alice:bar", membership: "join" } };
];
});
expect(room.hasMembershipState("@bob:bar", "join")).toBe(false); expect(room.hasMembershipState("@bob:bar", "join")).toBe(false);
}); });
it("should return false if match userId but no match membership", it("should return false if match userId but no match membership",
function() { function() {
room.currentState.getMembers.andCallFake(function() { room.currentState.members = {
return [ "@alice:bar": { userId: "@alice:bar", membership: "join" }
{ userId: "@alice:bar", membership: "join" } };
];
});
expect(room.hasMembershipState("@alice:bar", "ban")).toBe(false); expect(room.hasMembershipState("@alice:bar", "ban")).toBe(false);
}); });
it("should return false if no match membership or userId", it("should return false if no match membership or userId",
function() { function() {
room.currentState.getMembers.andCallFake(function() { room.currentState.members = {
return [ "@alice:bar": { userId: "@alice:bar", membership: "join" }
{ userId: "@alice:bar", membership: "join" } };
];
});
expect(room.hasMembershipState("@bob:bar", "invite")).toBe(false); expect(room.hasMembershipState("@bob:bar", "invite")).toBe(false);
}); });
it("should return false if no members exist", it("should return false if no members exist",
function() { function() {
room.currentState.getMembers.andCallFake(function() { room.currentState.members = {};
return [];
});
expect(room.hasMembershipState("@foo:bar", "join")).toBe(false); expect(room.hasMembershipState("@foo:bar", "join")).toBe(false);
}); });
}); });