mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-05 22:24:56 -04:00
Move getUserPowerLevel to modelService.
This commit is contained in:
parent
78bf5648e7
commit
b93804529d
5 changed files with 58 additions and 71 deletions
|
@ -67,51 +67,4 @@ describe('EventHandlerService', function() {
|
|||
var num = eventHandlerService.getUsersCountInRoom(roomId);
|
||||
expect(num).toEqual(2);
|
||||
}));
|
||||
|
||||
it('should be able to get a users power level', inject(
|
||||
function(eventHandlerService) {
|
||||
var roomId = "!foo:matrix.org";
|
||||
// set mocked data
|
||||
modelService.getRoom = function(roomId) {
|
||||
return {
|
||||
room_id: roomId,
|
||||
current_room_state: {
|
||||
members: {
|
||||
"@adam:matrix.org": {
|
||||
event: {
|
||||
content: { membership: "join" },
|
||||
user_id: "@adam:matrix.org"
|
||||
}
|
||||
},
|
||||
"@beth:matrix.org": {
|
||||
event: {
|
||||
content: { membership: "join" },
|
||||
user_id: "@beth:matrix.org"
|
||||
}
|
||||
}
|
||||
},
|
||||
s: {
|
||||
"m.room.power_levels": {
|
||||
content: {
|
||||
"@adam:matrix.org": 90,
|
||||
"default": 50
|
||||
}
|
||||
}
|
||||
},
|
||||
state: function(type, key) {
|
||||
return key ? this.s[type+key] : this.s[type]
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var num = eventHandlerService.getUserPowerLevel(roomId, "@beth:matrix.org");
|
||||
expect(num).toEqual(50);
|
||||
|
||||
num = eventHandlerService.getUserPowerLevel(roomId, "@adam:matrix.org");
|
||||
expect(num).toEqual(90);
|
||||
|
||||
num = eventHandlerService.getUserPowerLevel(roomId, "@unknown:matrix.org");
|
||||
expect(num).toEqual(50);
|
||||
}));
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue