summary refs log tree commit diff
path: root/syweb
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-11-12 16:32:17 +0000
committerKegan Dougal <kegan@matrix.org>2014-11-12 16:32:17 +0000
commit59cf6f5ec90ab0beac74739934b93c2c3163147e (patch)
tree4e0a9510f32ef160c4914c4c57f7c8a8ee9d2010 /syweb
parentAdd test coverage to the webclient. Update .gitignore (diff)
downloadsynapse-59cf6f5ec90ab0beac74739934b93c2c3163147e.tar.xz
Add more recents service unit tests.
Diffstat (limited to 'syweb')
-rw-r--r--syweb/webclient/test/unit/recents-service.spec.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/syweb/webclient/test/unit/recents-service.spec.js b/syweb/webclient/test/unit/recents-service.spec.js
index 93d351d45f..a2f9ecbaf8 100644
--- a/syweb/webclient/test/unit/recents-service.spec.js
+++ b/syweb/webclient/test/unit/recents-service.spec.js
@@ -112,4 +112,42 @@ describe('RecentsService', function() {
         expect(recentsService.getUnreadMessages()).toEqual({});
         expect(recentsService.getUnreadBingMessages()).toEqual({});
     }));
+    
+    it('should increment the unread message count.', inject(
+    function(recentsService) {
+        recentsService.setSelectedRoomId("!someotherroomid:localhost");
+        scope.$broadcast(MSG_EVENT, testEvent, testIsLive);
+    
+        var unread = {};
+        unread[testEvent.room_id] = 1;
+        expect(recentsService.getUnreadMessages()).toEqual(unread);
+        
+        scope.$broadcast(MSG_EVENT, testEvent, testIsLive);
+        
+        unread[testEvent.room_id] = 2;
+        expect(recentsService.getUnreadMessages()).toEqual(unread);
+    }));
+    
+    it('should set the bing event to the latest message to contain a bing word.', inject(
+    function(recentsService) {
+        recentsService.setSelectedRoomId("!someotherroomid:localhost");
+        testEventContainsBingWord = true;
+        scope.$broadcast(MSG_EVENT, testEvent, testIsLive);
+    
+        var nextEvent = angular.copy(testEvent);
+        nextEvent.content.body = "Goodbye cruel world.";
+        nextEvent.event_id = "erfuerhfeaaaa@localhost";
+        scope.$broadcast(MSG_EVENT, nextEvent, testIsLive);
+        
+        var bing = {};
+        bing[testEvent.room_id] = nextEvent;
+        expect(recentsService.getUnreadBingMessages()).toEqual(bing);
+    }));
+    
+    it('should do nothing when marking an unknown room ID as read.', inject(
+    function(recentsService) {
+        recentsService.markAsRead("!someotherroomid:localhost");
+        expect(recentsService.getUnreadMessages()).toEqual({});
+        expect(recentsService.getUnreadBingMessages()).toEqual({});
+    }));
 });