Fix tests. Emitted events weren't yet renamed in the tests.
This commit is contained in:
parent
9846f89a2c
commit
df91f17894
@ -162,14 +162,14 @@
|
|||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(controlview.close).toHaveBeenCalled();
|
expect(controlview.close).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxClosed', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||||
expect(converse.emit.callCount, 1);
|
expect(converse.emit.callCount, 1);
|
||||||
chatview.$el.find('.close-chatbox-button').click();
|
chatview.$el.find('.close-chatbox-button').click();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(chatview.close).toHaveBeenCalled();
|
expect(chatview.close).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxClosed', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||||
expect(converse.emit.callCount, 2);
|
expect(converse.emit.callCount, 2);
|
||||||
});
|
});
|
||||||
}, converse));
|
}, converse));
|
||||||
@ -190,7 +190,7 @@
|
|||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(chatview.minimize).toHaveBeenCalled();
|
expect(chatview.minimize).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxMinimized', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxMinimized', jasmine.any(Object));
|
||||||
expect(converse.emit.callCount, 2);
|
expect(converse.emit.callCount, 2);
|
||||||
expect(chatview.$el.is(':visible')).toBeFalsy();
|
expect(chatview.$el.is(':visible')).toBeFalsy();
|
||||||
expect(chatview.model.get('minimized')).toBeTruthy();
|
expect(chatview.model.get('minimized')).toBeTruthy();
|
||||||
@ -203,7 +203,7 @@
|
|||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(trimmedview.restore).toHaveBeenCalled();
|
expect(trimmedview.restore).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxMaximized', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxMaximized', jasmine.any(Object));
|
||||||
expect(chatview.$el.find('.chat-body').is(':visible')).toBeTruthy();
|
expect(chatview.$el.find('.chat-body').is(':visible')).toBeTruthy();
|
||||||
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeTruthy();
|
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-minus')).toBeTruthy();
|
||||||
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeFalsy();
|
expect(chatview.$el.find('.toggle-chatbox-button').hasClass('icon-plus')).toBeFalsy();
|
||||||
@ -220,18 +220,18 @@
|
|||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxClosed', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||||
expect(converse.chatboxes.length).toEqual(0);
|
expect(converse.chatboxes.length).toEqual(0);
|
||||||
utils.openChatBoxes(6);
|
utils.openChatBoxes(6);
|
||||||
expect(converse.chatboxviews.trimChats).toHaveBeenCalled();
|
expect(converse.chatboxviews.trimChats).toHaveBeenCalled();
|
||||||
expect(converse.chatboxes.length).toEqual(6);
|
expect(converse.chatboxes.length).toEqual(6);
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxOpened', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxOpened', jasmine.any(Object));
|
||||||
utils.closeAllChatBoxes();
|
utils.closeAllChatBoxes();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(converse.chatboxes.length).toEqual(0);
|
expect(converse.chatboxes.length).toEqual(0);
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxClosed', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||||
var newchatboxes = new this.ChatBoxes();
|
var newchatboxes = new this.ChatBoxes();
|
||||||
expect(newchatboxes.length).toEqual(0);
|
expect(newchatboxes.length).toEqual(0);
|
||||||
// onConnected will fetch chatboxes in browserStorage, but
|
// onConnected will fetch chatboxes in browserStorage, but
|
||||||
@ -352,7 +352,7 @@
|
|||||||
expect(callButton.length).toBe(0);
|
expect(callButton.length).toBe(0);
|
||||||
view.close();
|
view.close();
|
||||||
// Now check that it's shown if enabled and that it emits
|
// Now check that it's shown if enabled and that it emits
|
||||||
// onCallButtonClicked
|
// callButtonClicked
|
||||||
converse.visible_toolbar_buttons.call = true; // enable the button
|
converse.visible_toolbar_buttons.call = true; // enable the button
|
||||||
utils.openChatBoxFor(contact_jid);
|
utils.openChatBoxFor(contact_jid);
|
||||||
view = this.chatboxviews.get(contact_jid);
|
view = this.chatboxviews.get(contact_jid);
|
||||||
@ -360,7 +360,7 @@
|
|||||||
callButton = $toolbar.find('.toggle-call');
|
callButton = $toolbar.find('.toggle-call');
|
||||||
expect(callButton.length).toBe(1);
|
expect(callButton.length).toBe(1);
|
||||||
callButton.click();
|
callButton.click();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onCallButtonClicked', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('callButtonClicked', jasmine.any(Object));
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("can contain a button for clearing messages", $.proxy(function () {
|
it("can contain a button for clearing messages", $.proxy(function () {
|
||||||
@ -420,7 +420,7 @@
|
|||||||
runs($.proxy(function () {
|
runs($.proxy(function () {
|
||||||
// onMessage is a handler for received XMPP messages
|
// onMessage is a handler for received XMPP messages
|
||||||
this.chatboxes.onMessage(msg);
|
this.chatboxes.onMessage(msg);
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onMessage', msg);
|
expect(converse.emit).toHaveBeenCalledWith('message', msg);
|
||||||
}, converse));
|
}, converse));
|
||||||
waits(250);
|
waits(250);
|
||||||
runs($.proxy(function () {
|
runs($.proxy(function () {
|
||||||
@ -473,7 +473,7 @@
|
|||||||
}).c('body').t(message).up()
|
}).c('body').t(message).up()
|
||||||
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
|
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
|
||||||
this.chatboxes.onMessage(msg);
|
this.chatboxes.onMessage(msg);
|
||||||
expect(this.emit).toHaveBeenCalledWith('onMessage', msg);
|
expect(this.emit).toHaveBeenCalledWith('message', msg);
|
||||||
}, converse));
|
}, converse));
|
||||||
waits(50);
|
waits(50);
|
||||||
runs($.proxy(function () {
|
runs($.proxy(function () {
|
||||||
@ -535,7 +535,7 @@
|
|||||||
.c('delay', { xmlns:'urn:xmpp:delay', from: 'localhost', stamp: one_day_ago.format() })
|
.c('delay', { xmlns:'urn:xmpp:delay', from: 'localhost', stamp: one_day_ago.format() })
|
||||||
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
|
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
|
||||||
this.chatboxes.onMessage(msg);
|
this.chatboxes.onMessage(msg);
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onMessage', msg);
|
expect(converse.emit).toHaveBeenCalledWith('message', msg);
|
||||||
expect(chatbox.messages.length).toEqual(1);
|
expect(chatbox.messages.length).toEqual(1);
|
||||||
msg_obj = chatbox.messages.models[0];
|
msg_obj = chatbox.messages.models[0];
|
||||||
expect(msg_obj.get('message')).toEqual(message);
|
expect(msg_obj.get('message')).toEqual(message);
|
||||||
@ -556,7 +556,7 @@
|
|||||||
}).c('body').t(message).up()
|
}).c('body').t(message).up()
|
||||||
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
|
.c('active', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree();
|
||||||
this.chatboxes.onMessage(msg);
|
this.chatboxes.onMessage(msg);
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onMessage', msg);
|
expect(converse.emit).toHaveBeenCalledWith('message', msg);
|
||||||
// Check that there is a <time> element, with the required
|
// Check that there is a <time> element, with the required
|
||||||
// props.
|
// props.
|
||||||
var $time = $chat_content.find('time');
|
var $time = $chat_content.find('time');
|
||||||
@ -587,14 +587,14 @@
|
|||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxFocused', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxFocused', jasmine.any(Object));
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var view = this.chatboxviews.get(contact_jid);
|
||||||
var message = 'This message is sent from this chatbox';
|
var message = 'This message is sent from this chatbox';
|
||||||
spyOn(view, 'sendMessage').andCallThrough();
|
spyOn(view, 'sendMessage').andCallThrough();
|
||||||
utils.sendMessage(view, message);
|
utils.sendMessage(view, message);
|
||||||
expect(view.sendMessage).toHaveBeenCalled();
|
expect(view.sendMessage).toHaveBeenCalled();
|
||||||
expect(view.model.messages.length, 2);
|
expect(view.model.messages.length, 2);
|
||||||
expect(converse.emit.mostRecentCall.args, ['onMessageSend', message]);
|
expect(converse.emit.mostRecentCall.args, ['messageSend', message]);
|
||||||
expect(view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content').text()).toEqual(message);
|
expect(view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content').text()).toEqual(message);
|
||||||
}.bind(converse));
|
}.bind(converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
@ -709,7 +709,7 @@
|
|||||||
utils.sendMessage(view, message);
|
utils.sendMessage(view, message);
|
||||||
expect(view.model.messages.length > 0).toBeTruthy();
|
expect(view.model.messages.length > 0).toBeTruthy();
|
||||||
expect(view.model.messages.browserStorage.records.length > 0).toBeTruthy();
|
expect(view.model.messages.browserStorage.records.length > 0).toBeTruthy();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onMessageSend', message);
|
expect(converse.emit).toHaveBeenCalledWith('messageSend', message);
|
||||||
|
|
||||||
message = '/clear';
|
message = '/clear';
|
||||||
var old_length = view.model.messages.length;
|
var old_length = view.model.messages.length;
|
||||||
@ -725,7 +725,7 @@
|
|||||||
expect(view.model.messages.length, 0); // The messages must be removed from the chatbox
|
expect(view.model.messages.length, 0); // The messages must be removed from the chatbox
|
||||||
expect(view.model.messages.browserStorage.records.length, 0); // And also from browserStorage
|
expect(view.model.messages.browserStorage.records.length, 0); // And also from browserStorage
|
||||||
expect(converse.emit.callCount, 1);
|
expect(converse.emit.callCount, 1);
|
||||||
expect(converse.emit.mostRecentCall.args, ['onMessageSend', message]);
|
expect(converse.emit.mostRecentCall.args, ['messageSend', message]);
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
@ -751,7 +751,7 @@
|
|||||||
this.chatboxes.onMessage(msg);
|
this.chatboxes.onMessage(msg);
|
||||||
expect(converse.incrementMsgCounter).toHaveBeenCalled();
|
expect(converse.incrementMsgCounter).toHaveBeenCalled();
|
||||||
expect(this.msg_counter).toBe(1);
|
expect(this.msg_counter).toBe(1);
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onMessage', msg);
|
expect(converse.emit).toHaveBeenCalledWith('message', msg);
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("is cleared when the window is focused", $.proxy(function () {
|
it("is cleared when the window is focused", $.proxy(function () {
|
||||||
|
@ -85,7 +85,7 @@
|
|||||||
var $chat_content = view.$el.find('.chat-content');
|
var $chat_content = view.$el.find('.chat-content');
|
||||||
expect($chat_content.find('.chat-message').length).toBe(1);
|
expect($chat_content.find('.chat-message').length).toBe(1);
|
||||||
expect($chat_content.find('.chat-message-content').text()).toBe(text);
|
expect($chat_content.find('.chat-message-content').text()).toBe(text);
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onMessage', message.nodeTree);
|
expect(converse.emit).toHaveBeenCalledWith('message', message.nodeTree);
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("shows sent groupchat messages", $.proxy(function () {
|
it("shows sent groupchat messages", $.proxy(function () {
|
||||||
@ -96,7 +96,7 @@
|
|||||||
var text = 'This is a sent message';
|
var text = 'This is a sent message';
|
||||||
view.$el.find('.chat-textarea').text(text);
|
view.$el.find('.chat-textarea').text(text);
|
||||||
view.$el.find('textarea.chat-textarea').trigger($.Event('keypress', {keyCode: 13}));
|
view.$el.find('textarea.chat-textarea').trigger($.Event('keypress', {keyCode: 13}));
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onMessageSend', text);
|
expect(converse.emit).toHaveBeenCalledWith('messageSend', text);
|
||||||
|
|
||||||
var message = $msg({
|
var message = $msg({
|
||||||
from: 'lounge@muc.localhost/dummy',
|
from: 'lounge@muc.localhost/dummy',
|
||||||
@ -152,7 +152,7 @@
|
|||||||
waits(50);
|
waits(50);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(view.minimize).toHaveBeenCalled();
|
expect(view.minimize).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxMinimized', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxMinimized', jasmine.any(Object));
|
||||||
expect(converse.emit.callCount, 2);
|
expect(converse.emit.callCount, 2);
|
||||||
expect(view.$el.is(':visible')).toBeFalsy();
|
expect(view.$el.is(':visible')).toBeFalsy();
|
||||||
expect(view.model.get('minimized')).toBeTruthy();
|
expect(view.model.get('minimized')).toBeTruthy();
|
||||||
@ -163,7 +163,7 @@
|
|||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(view.maximize).toHaveBeenCalled();
|
expect(view.maximize).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onChatBoxMaximized', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxMaximized', jasmine.any(Object));
|
||||||
expect(view.$el.is(':visible')).toBeTruthy();
|
expect(view.$el.is(':visible')).toBeTruthy();
|
||||||
expect(view.model.get('minimized')).toBeFalsy();
|
expect(view.model.get('minimized')).toBeFalsy();
|
||||||
expect(converse.emit.callCount, 3);
|
expect(converse.emit.callCount, 3);
|
||||||
@ -184,7 +184,7 @@
|
|||||||
runs(function () {
|
runs(function () {
|
||||||
expect(view.close).toHaveBeenCalled();
|
expect(view.close).toHaveBeenCalled();
|
||||||
expect(this.connection.muc.leave).toHaveBeenCalled();
|
expect(this.connection.muc.leave).toHaveBeenCalled();
|
||||||
expect(this.emit).toHaveBeenCalledWith('onChatBoxClosed', jasmine.any(Object));
|
expect(this.emit).toHaveBeenCalledWith('chatBoxClosed', jasmine.any(Object));
|
||||||
}.bind(converse));
|
}.bind(converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
runs(function () {
|
runs(function () {
|
||||||
expect(this.controlboxtoggle.onClick).toHaveBeenCalled();
|
expect(this.controlboxtoggle.onClick).toHaveBeenCalled();
|
||||||
expect(this.controlboxtoggle.showControlBox).toHaveBeenCalled();
|
expect(this.controlboxtoggle.showControlBox).toHaveBeenCalled();
|
||||||
expect(this.emit).toHaveBeenCalledWith('onControlBoxOpened', jasmine.any(Object));
|
expect(this.emit).toHaveBeenCalledWith('controlBoxOpened', jasmine.any(Object));
|
||||||
expect($("div#controlbox").is(':visible')).toBe(true);
|
expect($("div#controlbox").is(':visible')).toBe(true);
|
||||||
}.bind(converse));
|
}.bind(converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
@ -67,7 +67,7 @@
|
|||||||
view.initialize(); // Rebind events for spy
|
view.initialize(); // Rebind events for spy
|
||||||
$(view.$el.find('.dropdown dd ul li a')[1]).click(); // Change status to "dnd"
|
$(view.$el.find('.dropdown dd ul li a')[1]).click(); // Change status to "dnd"
|
||||||
expect(view.setStatus).toHaveBeenCalled();
|
expect(view.setStatus).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onStatusChanged', 'dnd');
|
expect(converse.emit).toHaveBeenCalledWith('statusChanged', 'dnd');
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs($.proxy(function () {
|
runs($.proxy(function () {
|
||||||
@ -97,7 +97,7 @@
|
|||||||
runs (function () {
|
runs (function () {
|
||||||
view.$el.find('form#set-custom-xmpp-status').submit();
|
view.$el.find('form#set-custom-xmpp-status').submit();
|
||||||
expect(view.setStatusMessage).toHaveBeenCalled();
|
expect(view.setStatusMessage).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onStatusMessageChanged', msg);
|
expect(converse.emit).toHaveBeenCalledWith('statusMessageChanged', msg);
|
||||||
expect(view.$el.find('a.choose-xmpp-status').hasClass('online')).toBe(true);
|
expect(view.$el.find('a.choose-xmpp-status').hasClass('online')).toBe(true);
|
||||||
expect(view.$el.find('a.choose-xmpp-status').attr('data-value')).toBe(msg);
|
expect(view.$el.find('a.choose-xmpp-status').attr('data-value')).toBe(msg);
|
||||||
});
|
});
|
||||||
@ -143,7 +143,7 @@
|
|||||||
}, converse));
|
}, converse));
|
||||||
waits(300);
|
waits(300);
|
||||||
runs($.proxy(function () {
|
runs($.proxy(function () {
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
expect(this.rosterview.$el.is(':visible')).toEqual(true);
|
expect(this.rosterview.$el.is(':visible')).toEqual(true);
|
||||||
expect(this.rosterview.render).toHaveBeenCalled();
|
expect(this.rosterview.render).toHaveBeenCalled();
|
||||||
}, converse));
|
}, converse));
|
||||||
@ -165,7 +165,7 @@
|
|||||||
expect(this.rosterview.model.remove).toHaveBeenCalled();
|
expect(this.rosterview.model.remove).toHaveBeenCalled();
|
||||||
// The element must now be detached from the DOM.
|
// The element must now be detached from the DOM.
|
||||||
expect(view.$el.closest('html').length).toBeFalsy();
|
expect(view.$el.closest('html').length).toBeFalsy();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("will lose their own heading once the last one has been removed", $.proxy(function () {
|
it("will lose their own heading once the last one has been removed", $.proxy(function () {
|
||||||
@ -193,7 +193,7 @@
|
|||||||
is_last: is_last
|
is_last: is_last
|
||||||
});
|
});
|
||||||
expect(this.rosterview.render).toHaveBeenCalled();
|
expect(this.rosterview.render).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
// Check that they are sorted alphabetically
|
// Check that they are sorted alphabetically
|
||||||
t = this.rosterview.$el.find('dt#pending-xmpp-contacts').siblings('dd.pending-xmpp-contact').find('span').text();
|
t = this.rosterview.$el.find('dt#pending-xmpp-contacts').siblings('dd.pending-xmpp-contact').find('span').text();
|
||||||
expect(t).toEqual(mock.pend_names.slice(0,i+1).sort().join(''));
|
expect(t).toEqual(mock.pend_names.slice(0,i+1).sort().join(''));
|
||||||
@ -233,7 +233,7 @@
|
|||||||
is_last: i===(mock.cur_names.length-1)
|
is_last: i===(mock.cur_names.length-1)
|
||||||
});
|
});
|
||||||
expect(this.rosterview.render).toHaveBeenCalled();
|
expect(this.rosterview.render).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
// Check that they are sorted alphabetically
|
// Check that they are sorted alphabetically
|
||||||
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.offline').find('a.open-chat').text();
|
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.offline').find('a.open-chat').text();
|
||||||
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
||||||
@ -256,7 +256,7 @@
|
|||||||
item.set('chat_status', 'online');
|
item.set('chat_status', 'online');
|
||||||
expect(view.render).toHaveBeenCalled();
|
expect(view.render).toHaveBeenCalled();
|
||||||
expect(this.rosterview.render).toHaveBeenCalled();
|
expect(this.rosterview.render).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
// Check that they are sorted alphabetically
|
// Check that they are sorted alphabetically
|
||||||
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.online').find('a.open-chat').text();
|
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.online').find('a.open-chat').text();
|
||||||
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
||||||
@ -275,7 +275,7 @@
|
|||||||
item.set('chat_status', 'dnd');
|
item.set('chat_status', 'dnd');
|
||||||
expect(view.render).toHaveBeenCalled();
|
expect(view.render).toHaveBeenCalled();
|
||||||
expect(this.rosterview.render).toHaveBeenCalled();
|
expect(this.rosterview.render).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
// Check that they are sorted alphabetically
|
// Check that they are sorted alphabetically
|
||||||
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.dnd').find('a.open-chat').text();
|
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.dnd').find('a.open-chat').text();
|
||||||
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
||||||
@ -294,7 +294,7 @@
|
|||||||
item.set('chat_status', 'away');
|
item.set('chat_status', 'away');
|
||||||
expect(view.render).toHaveBeenCalled();
|
expect(view.render).toHaveBeenCalled();
|
||||||
expect(this.rosterview.render).toHaveBeenCalled();
|
expect(this.rosterview.render).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
// Check that they are sorted alphabetically
|
// Check that they are sorted alphabetically
|
||||||
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.away').find('a.open-chat').text();
|
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.away').find('a.open-chat').text();
|
||||||
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
||||||
@ -313,7 +313,7 @@
|
|||||||
item.set('chat_status', 'xa');
|
item.set('chat_status', 'xa');
|
||||||
expect(view.render).toHaveBeenCalled();
|
expect(view.render).toHaveBeenCalled();
|
||||||
expect(this.rosterview.render).toHaveBeenCalled();
|
expect(this.rosterview.render).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
// Check that they are sorted alphabetically
|
// Check that they are sorted alphabetically
|
||||||
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.xa').find('a.open-chat').text();
|
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.xa').find('a.open-chat').text();
|
||||||
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
expect(t).toEqual(mock.cur_names.slice(0,i+1).sort().join(''));
|
||||||
@ -332,7 +332,7 @@
|
|||||||
item.set('chat_status', 'unavailable');
|
item.set('chat_status', 'unavailable');
|
||||||
expect(view.render).toHaveBeenCalled();
|
expect(view.render).toHaveBeenCalled();
|
||||||
expect(this.rosterview.render).toHaveBeenCalled();
|
expect(this.rosterview.render).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
// Check that they are sorted alphabetically
|
// Check that they are sorted alphabetically
|
||||||
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.unavailable').find('a.open-chat').text();
|
t = this.rosterview.$el.find('dt#xmpp-contacts').siblings('dd.current-xmpp-contact.unavailable').find('a.open-chat').text();
|
||||||
expect(t).toEqual(mock.cur_names.slice(0, i+1).sort().join(''));
|
expect(t).toEqual(mock.cur_names.slice(0, i+1).sort().join(''));
|
||||||
@ -430,7 +430,7 @@
|
|||||||
// When a requesting contact is added, the controlbox must
|
// When a requesting contact is added, the controlbox must
|
||||||
// be opened.
|
// be opened.
|
||||||
expect(this.controlboxtoggle.showControlBox).toHaveBeenCalled();
|
expect(this.controlboxtoggle.showControlBox).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
}
|
}
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
@ -466,7 +466,7 @@
|
|||||||
expect(view.declineRequest).toHaveBeenCalled();
|
expect(view.declineRequest).toHaveBeenCalled();
|
||||||
expect(this.rosterview.removeRosterItemView).toHaveBeenCalled();
|
expect(this.rosterview.removeRosterItemView).toHaveBeenCalled();
|
||||||
expect(this.connection.roster.unauthorize).toHaveBeenCalled();
|
expect(this.connection.roster.unauthorize).toHaveBeenCalled();
|
||||||
expect(converse.emit).toHaveBeenCalledWith('onRosterViewUpdated');
|
expect(converse.emit).toHaveBeenCalledWith('rosterViewUpdated');
|
||||||
// There should now be one less contact
|
// There should now be one less contact
|
||||||
expect(this.roster.length).toEqual(mock.req_names.length-1);
|
expect(this.roster.length).toEqual(mock.req_names.length-1);
|
||||||
}, converse));
|
}, converse));
|
||||||
|
@ -14,24 +14,24 @@
|
|||||||
it("allows you to subscribe to emitted events", function () {
|
it("allows you to subscribe to emitted events", function () {
|
||||||
this.callback = function () {};
|
this.callback = function () {};
|
||||||
spyOn(this, 'callback');
|
spyOn(this, 'callback');
|
||||||
converse.on('onInitialized', this.callback);
|
converse.on('initialized', this.callback);
|
||||||
converse.emit('onInitialized');
|
converse.emit('initialized');
|
||||||
expect(this.callback).toHaveBeenCalled();
|
expect(this.callback).toHaveBeenCalled();
|
||||||
converse.emit('onInitialized');
|
converse.emit('initialized');
|
||||||
expect(this.callback.callCount, 2);
|
expect(this.callback.callCount, 2);
|
||||||
converse.emit('onInitialized');
|
converse.emit('initialized');
|
||||||
expect(this.callback.callCount, 3);
|
expect(this.callback.callCount, 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows you to listen once for an emitted event", function () {
|
it("allows you to listen once for an emitted event", function () {
|
||||||
this.callback = function () {};
|
this.callback = function () {};
|
||||||
spyOn(this, 'callback');
|
spyOn(this, 'callback');
|
||||||
converse.once('onInitialized', this.callback);
|
converse.once('initialized', this.callback);
|
||||||
converse.emit('onInitialized');
|
converse.emit('initialized');
|
||||||
expect(this.callback).toHaveBeenCalled();
|
expect(this.callback).toHaveBeenCalled();
|
||||||
converse.emit('onInitialized');
|
converse.emit('initialized');
|
||||||
expect(this.callback.callCount, 1);
|
expect(this.callback.callCount, 1);
|
||||||
converse.emit('onInitialized');
|
converse.emit('initialized');
|
||||||
expect(this.callback.callCount, 1);
|
expect(this.callback.callCount, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -43,23 +43,23 @@
|
|||||||
spyOn(this, 'callback');
|
spyOn(this, 'callback');
|
||||||
spyOn(this, 'anotherCallback');
|
spyOn(this, 'anotherCallback');
|
||||||
spyOn(this, 'neverCalled');
|
spyOn(this, 'neverCalled');
|
||||||
converse.on('onInitialized', this.callback);
|
converse.on('initialized', this.callback);
|
||||||
converse.on('onInitialized', this.anotherCallback);
|
converse.on('initialized', this.anotherCallback);
|
||||||
|
|
||||||
converse.emit('onInitialized');
|
converse.emit('initialized');
|
||||||
expect(this.callback).toHaveBeenCalled();
|
expect(this.callback).toHaveBeenCalled();
|
||||||
expect(this.anotherCallback).toHaveBeenCalled();
|
expect(this.anotherCallback).toHaveBeenCalled();
|
||||||
|
|
||||||
converse.off('onInitialized', this.callback);
|
converse.off('initialized', this.callback);
|
||||||
|
|
||||||
converse.emit('onInitialized');
|
converse.emit('initialized');
|
||||||
expect(this.callback.callCount, 1);
|
expect(this.callback.callCount, 1);
|
||||||
expect(this.anotherCallback.callCount, 2);
|
expect(this.anotherCallback.callCount, 2);
|
||||||
|
|
||||||
converse.once('onInitialized', this.neverCalled);
|
converse.once('initialized', this.neverCalled);
|
||||||
converse.off('onInitialized', this.neverCalled);
|
converse.off('initialized', this.neverCalled);
|
||||||
|
|
||||||
converse.emit('onInitialized');
|
converse.emit('initialized');
|
||||||
expect(this.callback.callCount, 1);
|
expect(this.callback.callCount, 1);
|
||||||
expect(this.anotherCallback.callCount, 3);
|
expect(this.anotherCallback.callCount, 3);
|
||||||
expect(this.neverCalled).not.toHaveBeenCalled();
|
expect(this.neverCalled).not.toHaveBeenCalled();
|
||||||
|
Loading…
Reference in New Issue
Block a user