소스 검색

Test chatroom message

JC Brand 12 년 전
부모
커밋
b35d71e22f
2개의 변경된 파일21개의 추가작업 그리고 1개의 파일을 삭제
  1. 21 0
      spec/ChatRoomSpec.js
  2. 0 1
      spec/MainSpec.js

+ 21 - 0
spec/ChatRoomSpec.js

@@ -11,6 +11,10 @@
         var chatroom_names = [
             'Dyon van de Wege', 'Thomas Kalb', 'Dirk Theissen', 'Felix Hofmann', 'Ka Lek', 'Anne Ebersbacher'
         ];
+        closeChatRoom = function (name) {
+            converse.chatboxesview.views['lounge@muc.localhost'].closeChat();
+        };
+
         describe("A Chat Room", $.proxy(function () {
             beforeEach($.proxy(function () {
                 if (!$("div#controlbox").is(':visible')) {
@@ -54,6 +58,23 @@
                 expect($(occupant).attr('title')).toBe('This user is a moderator');
             }, converse));
 
+            it("shows received and sent groupchat messages", $.proxy(function () {
+                var view = this.chatboxesview.views['lounge@muc.localhost'];
+                if (!view.$el.find('.chat-area').length) { view.renderChatArea(); }
+                var nick = chatroom_names[0];
+                var text = 'This is a received message';
+                var message = $msg({
+                    from: 'lounge@muc.localhost/'+nick,
+                    id: '1',
+                    to: 'dummy@localhost',
+                    type: 'groupchat'
+                }).c('body').t(text);
+                view.onChatRoomMessage(message.nodeTree);
+                var $chat_content = view.$el.find('.chat-content');
+                expect($chat_content.find('.chat-message').length).toBe(1);
+                expect($chat_content.find('.chat-message-content').text()).toBe(text);
+            }, converse));
+
             it("can be saved to, and retrieved from, localStorage", $.proxy(function () {
                 // We instantiate a new ChatBoxes collection, which by default
                 // will be empty.

+ 0 - 1
spec/MainSpec.js

@@ -32,7 +32,6 @@
         };
 
         openControlBox = function () {
-            // Make sure the controlbox is open
             if (!$("div#controlbox").is(':visible')) {
                 $('.toggle-online-users').click();
             }