From 1cfbe0cc8dcf77053cb58e175183def0ee48bef2 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Tue, 16 Apr 2013 21:40:48 +0200 Subject: [PATCH] Add more tests for chat messages --- spec/MainSpec.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/spec/MainSpec.js b/spec/MainSpec.js index b5c6da655..639294eb3 100644 --- a/spec/MainSpec.js +++ b/spec/MainSpec.js @@ -44,6 +44,9 @@ 'get': function () {}, 'subscribe': function () {}, 'registerCallback': function () {} + }, + 'vcard': { + 'get': function () {} } }; @@ -366,9 +369,9 @@ }, xmppchat)); }, xmppchat)); - describe("Chatboxes", $.proxy(function () { + describe("A Chatbox", $.proxy(function () { - it("are created when you click on a roster item", $.proxy(function () { + it("is created when you click on a roster item", $.proxy(function () { var i, $el, click, jid, view; // showControlBox was called earlier, so the controlbox is // visible, but no other chat boxes have been created. @@ -430,6 +433,29 @@ this.chatboxes.onConnected(); expect(this.chatboxes.length).toEqual(0); }, xmppchat)); + + describe("A Chat Message", $.proxy(function () { + it("received from a contact will open a chatbox and appear inside it", $.proxy(function () { + var sender_jid = cur_names[0].replace(' ','.').toLowerCase() + '@localhost'; + var timestamp = (new Date()).getTime(), + msg = $msg({ + from: sender_jid, + to: this.bare_jid, + type: 'chat', + id: timestamp + }).c('body').t('This is a received message').up() + .c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree(); + + var chatbox = this.chatboxesview.views[sender_jid].model; + spyOn(chatbox, 'messageReceived'); + this.chatboxes.messageReceived(msg); + expect(chatbox.messageReceived).toHaveBeenCalled(); + }, xmppchat)); + + it("can be sent from a chatbox, and will appear inside it", $.proxy(function () { + var hello; + }, xmppchat)); + }, xmppchat)); }, xmppchat)); }, xmppchat));