Add another test

Test that chatboxes can also be closed.
This commit is contained in:
JC Brand 2013-04-13 01:24:55 +02:00
parent acf3f75b7d
commit 66dde5e986

View File

@ -132,7 +132,7 @@
expect(this.rosterview.$el.find('dt#xmpp-contacts').css('display')).toEqual('block'); expect(this.rosterview.$el.find('dt#xmpp-contacts').css('display')).toEqual('block');
}, xmppchat)); }, xmppchat));
describe("roster items", $.proxy(function () { describe("Roster items", $.proxy(function () {
it("are saved to, and can be retrieved from, localStorage", $.proxy(function () { it("are saved to, and can be retrieved from, localStorage", $.proxy(function () {
var new_attrs, old_attrs, attrs, old_roster; var new_attrs, old_attrs, attrs, old_roster;
@ -274,9 +274,8 @@
jid = $el.text().replace(' ','.').toLowerCase() + '@localhost'; jid = $el.text().replace(' ','.').toLowerCase() + '@localhost';
view = this.rosterview.rosteritemviews[jid]; view = this.rosterview.rosteritemviews[jid];
spyOn(view, 'openChat').andCallThrough(); spyOn(view, 'openChat').andCallThrough();
// We need to rebind all events otherwise our spy won't work. view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
view.delegateEvents(); $el.click();
var ev = $el.click();
expect(view.openChat).toHaveBeenCalled(); expect(view.openChat).toHaveBeenCalled();
expect(this.chatboxes.length).toEqual(i+2); expect(this.chatboxes.length).toEqual(i+2);
} }
@ -301,6 +300,21 @@
} }
this.rosterview.render(); this.rosterview.render();
}, xmppchat)); }, xmppchat));
it("can be closed again", $.proxy(function () {
var chatbox, view, $el;
for (i=0; i<this.chatboxes.length; i++) {
chatbox = this.chatboxes.models[i];
if (chatbox.get('id') == 'controlbox') {
continue;
}
view = this.chatboxesview.views[chatbox.get('jid')];
spyOn(view, 'closeChat').andCallThrough();
view.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
view.$el.find('.close-chatbox-button').click();
expect(view.closeChat).toHaveBeenCalled();
}
}, xmppchat));
}, xmppchat)); }, xmppchat));
}, xmppchat)); }, xmppchat));