summary refs log tree commit diff
path: root/syweb/webclient/test/unit/model-service.spec.js
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-11-14 16:15:32 +0000
committerKegan Dougal <kegan@matrix.org>2014-11-14 16:15:32 +0000
commitb93804529db45ab8bc5e320bdb9b34e9580e111a (patch)
tree976f187344f727b31b307c9bbe4d0ac84c87ce61 /syweb/webclient/test/unit/model-service.spec.js
parentFix bug which caused notifications to appear for old messages. (diff)
downloadsynapse-b93804529db45ab8bc5e320bdb9b34e9580e111a.tar.xz
Move getUserPowerLevel to modelService.
Diffstat (limited to 'syweb/webclient/test/unit/model-service.spec.js')
-rw-r--r--syweb/webclient/test/unit/model-service.spec.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/syweb/webclient/test/unit/model-service.spec.js b/syweb/webclient/test/unit/model-service.spec.js
index e2fa8ceba3..b99a76310b 100644
--- a/syweb/webclient/test/unit/model-service.spec.js
+++ b/syweb/webclient/test/unit/model-service.spec.js
@@ -27,4 +27,38 @@ describe('ModelService', function() {
         var user = modelService.getMember(roomId, userId);
         expect(user.event.state_key).toEqual(userId);
     }));
+    
+    it('should be able to get a users power level', inject(
+    function(modelService) {
+        var roomId = "!foo:matrix.org";
+        
+        var room = modelService.getRoom(roomId);
+        room.current_room_state.storeStateEvent({
+            content: { membership: "join" },
+            user_id: "@adam:matrix.org",
+            type: "m.room.member"
+        });
+        room.current_room_state.storeStateEvent({
+            content: { membership: "join" },
+            user_id: "@beth:matrix.org",
+            type: "m.room.member"
+        });
+        room.current_room_state.storeStateEvent({
+            content: {
+                "@adam:matrix.org": 90,
+                "default": 50
+            },
+            user_id: "@adam:matrix.org",
+            type: "m.room.power_levels"
+        });
+        
+        var num = modelService.getUserPowerLevel(roomId, "@beth:matrix.org");
+        expect(num).toEqual(50);
+        
+        num = modelService.getUserPowerLevel(roomId, "@adam:matrix.org");
+        expect(num).toEqual(90);
+        
+        num = modelService.getUserPowerLevel(roomId, "@unknown:matrix.org");
+        expect(num).toEqual(50);
+    }));
 });