Commit 0f0599d5 authored by JC Brand's avatar JC Brand

Extended the test

parent 8525ee50
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
'listRooms': function () {} 'listRooms': function () {}
} }
}; };
this.bare_jid = 'dummy@localhost';
this.prebind = true; this.prebind = true;
this.connection = mock_connection; this.connection = mock_connection;
this.chatboxes = new this.ChatBoxes(); this.chatboxes = new this.ChatBoxes();
...@@ -38,6 +39,8 @@ ...@@ -38,6 +39,8 @@
window.localStorage.removeItem(key); window.localStorage.removeItem(key);
this.roster.localStorage = new Backbone.LocalStorage(key); this.roster.localStorage = new Backbone.LocalStorage(key);
window.localStorage.removeItem(
hex_sha1('converse.chatboxes-'+this.bare_jid));
this.chatboxes.onConnected(); this.chatboxes.onConnected();
this.rosterview = new this.RosterView({'model':this.roster}); this.rosterview = new this.RosterView({'model':this.roster});
this.rosterview.render(); this.rosterview.render();
...@@ -259,15 +262,24 @@ ...@@ -259,15 +262,24 @@
describe("Chatboxes", $.proxy(function () { describe("Chatboxes", $.proxy(function () {
it("are created when you click on a roster item", $.proxy(function () { it("are created when you click on a roster item", $.proxy(function () {
var $el = $(this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.online').find('a.open-chat')[0]); var i, $el, click, jid, view;
var click = jQuery.Event("click", { target: $el }); // showControlBox was called earlier, so the controlbox is
var jid = $el.text().replace(' ','.').toLowerCase() + '@localhost'; // visible, but no other chat boxes have been created.
var view = this.rosterview.rosteritemviews[jid]; expect(this.chatboxes.length).toEqual(1);
spyOn(view, 'openChat');
// We need to rebind all events otherwise our spy won't work. var online_contacts = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.online').find('a.open-chat');
view.delegateEvents(); for (i=0; i<online_contacts.length; i++) {
var ev = $el.click(); $el = $(online_contacts[i]);
expect(view.openChat).toHaveBeenCalled(); click = jQuery.Event("click", { target: $el });
jid = $el.text().replace(' ','.').toLowerCase() + '@localhost';
view = this.rosterview.rosteritemviews[jid];
spyOn(view, 'openChat').andCallThrough();
// We need to rebind all events otherwise our spy won't work.
view.delegateEvents();
var ev = $el.click();
expect(view.openChat).toHaveBeenCalled();
expect(this.chatboxes.length).toEqual(i+2);
}
}, xmppchat)); }, xmppchat));
}, xmppchat)); }, xmppchat));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment