瀏覽代碼

Fix tests. Make sure the min chats toggle gets updated

JC Brand 11 年之前
父節點
當前提交
180d175e54
共有 4 個文件被更改,包括 5 次插入7 次删除
  1. 2 2
      converse.js
  2. 0 2
      spec/chatbox.js
  3. 2 2
      spec/controlbox.js
  4. 1 1
      spec/minchats.js

+ 2 - 2
converse.js

@@ -2650,8 +2650,7 @@
             },
             },
 
 
             updateUnreadMessagesCounter: function () {
             updateUnreadMessagesCounter: function () {
-                var count = this.model.get('num_unread') + 1;
-                this.model.set({'num_unread': count});
+                this.model.set({'num_unread': this.model.get('num_unread') + 1});
                 this.render();
                 this.render();
             },
             },
 
 
@@ -2765,6 +2764,7 @@
 
 
             initialize: function () {
             initialize: function () {
                 this.model.on('change:num_minimized', this.render, this);
                 this.model.on('change:num_minimized', this.render, this);
+                this.model.on('change:num_unread', this.render, this);
                 this.$flyout = this.$el.siblings('.minimized-chats-flyout');
                 this.$flyout = this.$el.siblings('.minimized-chats-flyout');
             },
             },
 
 

+ 0 - 2
spec/chatbox.js

@@ -483,7 +483,6 @@
                         var $count = trimmedview.$el.find('.chat-head-message-count');
                         var $count = trimmedview.$el.find('.chat-head-message-count');
                         expect(trimmedview.model.get('minimized')).toBeTruthy();
                         expect(trimmedview.model.get('minimized')).toBeTruthy();
                         expect($count.is(':visible')).toBeTruthy();
                         expect($count.is(':visible')).toBeTruthy();
-                        expect($count.data('count')).toBe(1);
                         expect($count.html()).toBe('1');
                         expect($count.html()).toBe('1');
                         this.chatboxes.onMessage(
                         this.chatboxes.onMessage(
                             $msg({
                             $msg({
@@ -502,7 +501,6 @@
                         var $count = trimmedview.$el.find('.chat-head-message-count');
                         var $count = trimmedview.$el.find('.chat-head-message-count');
                         expect(trimmedview.model.get('minimized')).toBeTruthy();
                         expect(trimmedview.model.get('minimized')).toBeTruthy();
                         expect($count.is(':visible')).toBeTruthy();
                         expect($count.is(':visible')).toBeTruthy();
-                        expect($count.data('count')).toBe(2);
                         expect($count.html()).toBe('2');
                         expect($count.html()).toBe('2');
                         trimmedview.$el.find('.restore-chat').click();
                         trimmedview.$el.find('.restore-chat').click();
                     }, converse));
                     }, converse));

+ 2 - 2
spec/controlbox.js

@@ -18,7 +18,7 @@
             runs(function () {
             runs(function () {
                 utils.closeControlBox();
                 utils.closeControlBox();
             });
             });
-            waits(250);
+            waits(50);
             runs(function () {
             runs(function () {
                 // This spec will only pass if the controlbox is not currently
                 // This spec will only pass if the controlbox is not currently
                 // open yet.
                 // open yet.
@@ -30,7 +30,7 @@
                 this.controlboxtoggle.delegateEvents();
                 this.controlboxtoggle.delegateEvents();
                 $('.toggle-controlbox').click();
                 $('.toggle-controlbox').click();
             }.bind(converse));
             }.bind(converse));
-            waits(250);
+            waits(50);
             runs(function () {
             runs(function () {
                 expect(this.controlboxtoggle.onClick).toHaveBeenCalled();
                 expect(this.controlboxtoggle.onClick).toHaveBeenCalled();
                 expect(this.controlboxtoggle.showControlBox).toHaveBeenCalled();
                 expect(this.controlboxtoggle.showControlBox).toHaveBeenCalled();

+ 1 - 1
spec/minchats.js

@@ -82,7 +82,7 @@
                 .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
                 .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
                 this.chatboxes.onMessage(msg);
                 this.chatboxes.onMessage(msg);
                 expect(this.minimized_chats.toggleview.$('.unread-message-count').is(':visible')).toBeTruthy();
                 expect(this.minimized_chats.toggleview.$('.unread-message-count').is(':visible')).toBeTruthy();
-                expect(this.minimized_chats.toggleview.$('.unread-message-count').text()).toBe(i.toString());
+                expect(this.minimized_chats.toggleview.$('.unread-message-count').text()).toBe((i+1).toString());
             }
             }
         }, converse));
         }, converse));