From b35d71e22fd648b49e0e2c0c31e03b806dc7b2e3 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 14 May 2013 23:20:59 +0200 Subject: [PATCH] Test chatroom message --- spec/ChatRoomSpec.js | 21 +++++++++++++++++++++ spec/MainSpec.js | 1 - 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/spec/ChatRoomSpec.js b/spec/ChatRoomSpec.js index b10e39009..4534ab7c2 100644 --- a/spec/ChatRoomSpec.js +++ b/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. diff --git a/spec/MainSpec.js b/spec/MainSpec.js index 8f80fbabd..95d766d45 100644 --- a/spec/MainSpec.js +++ b/spec/MainSpec.js @@ -32,7 +32,6 @@ }; openControlBox = function () { - // Make sure the controlbox is open if (!$("div#controlbox").is(':visible')) { $('.toggle-online-users').click(); }