Add test for restoring of trimmed chats
This commit is contained in:
parent
c594e5a1e9
commit
88d20d0372
@ -57,16 +57,16 @@
|
|||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("can be trimmed to conserve space", $.proxy(function () {
|
it("can be trimmed to conserve space", $.proxy(function () {
|
||||||
var i, $el, click, jid, view, chatboxview;
|
var i, $el, click, jid, key, view, chatboxview;
|
||||||
// openControlBox was called earlier, so the controlbox is
|
// openControlBox was called earlier, so the controlbox is
|
||||||
// visible, but no other chat boxes have been created.
|
// visible, but no other chat boxes have been created.
|
||||||
var trimmed_chatboxes = converse.chatboxviews.trimmed_chatboxes_view;
|
var trimmed_chatboxes = converse.chatboxviews.trimmed_chatboxes_view;
|
||||||
expect(this.chatboxes.length).toEqual(1);
|
expect(this.chatboxes.length).toEqual(1);
|
||||||
spyOn(this.chatboxviews, 'trimChats');
|
spyOn(this.chatboxviews, 'trimChats');
|
||||||
spyOn(trimmed_chatboxes, 'onChanged').andCallThrough();
|
spyOn(trimmed_chatboxes, 'onChanged').andCallThrough();
|
||||||
|
|
||||||
expect($("#conversejs .chatbox").length).toBe(1); // Controlbox is open
|
expect($("#conversejs .chatbox").length).toBe(1); // Controlbox is open
|
||||||
|
|
||||||
|
// Test that they can be trimmed
|
||||||
var online_contacts = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact').find('a.open-chat');
|
var online_contacts = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact').find('a.open-chat');
|
||||||
for (i=0; i<online_contacts.length; i++) {
|
for (i=0; i<online_contacts.length; i++) {
|
||||||
$el = $(online_contacts[i]);
|
$el = $(online_contacts[i]);
|
||||||
@ -79,13 +79,26 @@
|
|||||||
chatboxview = this.chatboxviews.get(jid);
|
chatboxview = this.chatboxviews.get(jid);
|
||||||
spyOn(chatboxview, 'trim').andCallThrough();
|
spyOn(chatboxview, 'trim').andCallThrough();
|
||||||
chatboxview.model.set({'trimmed': true});
|
chatboxview.model.set({'trimmed': true});
|
||||||
|
|
||||||
expect(trimmed_chatboxes.onChanged).toHaveBeenCalled();
|
expect(trimmed_chatboxes.onChanged).toHaveBeenCalled();
|
||||||
expect(chatboxview.trim).toHaveBeenCalled();
|
expect(chatboxview.trim).toHaveBeenCalled();
|
||||||
|
|
||||||
trimmedview = trimmed_chatboxes.get(jid);
|
trimmedview = trimmed_chatboxes.get(jid);
|
||||||
expect(trimmedview.$el.is(":visible")).toBeTruthy();
|
expect(trimmedview.$el.is(":visible")).toBeTruthy();
|
||||||
}
|
}
|
||||||
|
// Test that they can be restored/grown again
|
||||||
|
var chatboxviews = this.chatboxviews.getAll();
|
||||||
|
var keys = _.keys(chatboxviews);
|
||||||
|
for (i=0; i<keys.length; i++) {
|
||||||
|
key = keys[i];
|
||||||
|
if (key === 'controlbox') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
chatboxview = chatboxviews[key];
|
||||||
|
trimmedview = trimmed_chatboxes.get(key);
|
||||||
|
spyOn(chatboxview, 'grow').andCallThrough();
|
||||||
|
trimmedview.$("a.restore-chat").click();
|
||||||
|
expect(trimmed_chatboxes.onChanged).toHaveBeenCalled();
|
||||||
|
expect(chatboxview.grow).toHaveBeenCalled();
|
||||||
|
}
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("is focused if its already open and you click on its corresponding roster item", $.proxy(function () {
|
it("is focused if its already open and you click on its corresponding roster item", $.proxy(function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user