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 4639a6984c..d92930e2e0 100644
--- a/syweb/webclient/test/unit/model-service.spec.js
+++ b/syweb/webclient/test/unit/model-service.spec.js
@@ -193,4 +193,38 @@ describe('ModelService', function() {
 
         
     }));
+    
+    it('should be able to get the number of joined users in a room', inject(
+    function(modelService) {
+        var roomId = "!foo:matrix.org";
+        // set mocked data
+        var room = modelService.getRoom(roomId);
+        room.current_room_state.storeStateEvent({
+            content: { membership: "join" },
+            user_id: "@adam:matrix.org",
+            state_key: "@adam:matrix.org",
+            type: "m.room.member"
+        });
+        room.current_room_state.storeStateEvent({
+            content: { membership: "invite" },
+            user_id: "@adam:matrix.org",
+            state_key: "@beth:matrix.org",
+            type: "m.room.member"
+        });
+        room.current_room_state.storeStateEvent({
+            content: { membership: "join" },
+            user_id: "@charlie:matrix.org",
+            state_key: "@charlie:matrix.org",
+            type: "m.room.member"
+        });
+        room.current_room_state.storeStateEvent({
+            content: { membership: "leave" },
+            user_id: "@danice:matrix.org",
+            state_key: "@danice:matrix.org",
+            type: "m.room.member"
+        });
+        
+        var num = modelService.getUserCountInRoom(roomId);
+        expect(num).toEqual(2);
+    }));
 });