summary refs log tree commit diff
path: root/syweb/webclient/test/unit/model-service.spec.js
diff options
context:
space:
mode:
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);
+    }));
 });