Let tests pass again
This commit is contained in:
parent
729bea2abb
commit
e7d563b34b
2
main.js
2
main.js
@ -75,7 +75,7 @@ config = {
|
|||||||
'bigint': { deps: ['crypto'] },
|
'bigint': { deps: ['crypto'] },
|
||||||
'jquery.browser': { deps: ['jquery'] },
|
'jquery.browser': { deps: ['jquery'] },
|
||||||
'jquery.easing': { deps: ['jquery'] },
|
'jquery.easing': { deps: ['jquery'] },
|
||||||
'utils':{ deps: ['jquery'] },
|
'utils': { deps: ['jquery'] },
|
||||||
'strophe': { deps: ['jquery'] },
|
'strophe': { deps: ['jquery'] },
|
||||||
'strophe.disco': { deps: ['strophe'] },
|
'strophe.disco': { deps: ['strophe'] },
|
||||||
'strophe.muc': { deps: ['strophe', 'jquery'] },
|
'strophe.muc': { deps: ['strophe', 'jquery'] },
|
||||||
|
108
spec/chatbox.js
108
spec/chatbox.js
@ -1,23 +1,23 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([
|
define([
|
||||||
"mock",
|
"mock",
|
||||||
"utils"
|
"test_utils"
|
||||||
], function (mock, utils) {
|
], function (mock, test_utils) {
|
||||||
return factory(mock, utils);
|
return factory(mock, test_utils);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} (this, function (mock, utils) {
|
} (this, function (mock, test_utils) {
|
||||||
return describe("Chatboxes", $.proxy(function(mock, utils) {
|
return describe("Chatboxes", $.proxy(function(mock, test_utils) {
|
||||||
describe("A Chatbox", $.proxy(function () {
|
describe("A Chatbox", $.proxy(function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.closeAllChatBoxes();
|
test_utils.closeAllChatBoxes();
|
||||||
utils.removeControlBox();
|
test_utils.removeControlBox();
|
||||||
utils.clearBrowserStorage();
|
test_utils.clearBrowserStorage();
|
||||||
utils.initConverse();
|
test_utils.initConverse();
|
||||||
utils.createContacts();
|
test_utils.createContacts();
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
utils.openContactsPanel();
|
test_utils.openContactsPanel();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -95,7 +95,7 @@
|
|||||||
// 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.
|
||||||
expect(this.chatboxes.length).toEqual(1);
|
expect(this.chatboxes.length).toEqual(1);
|
||||||
chatbox = utils.openChatBoxFor(contact_jid);
|
chatbox = test_utils.openChatBoxFor(contact_jid);
|
||||||
chatboxview = this.chatboxviews.get(contact_jid);
|
chatboxview = this.chatboxviews.get(contact_jid);
|
||||||
spyOn(chatboxview, 'focus');
|
spyOn(chatboxview, 'focus');
|
||||||
$el = this.rosterview.$el.find('a.open-chat:contains("'+chatbox.get('fullname')+'")');
|
$el = this.rosterview.$el.find('a.open-chat:contains("'+chatbox.get('fullname')+'")');
|
||||||
@ -109,11 +109,11 @@
|
|||||||
spyOn(converse, 'emit');
|
spyOn(converse, 'emit');
|
||||||
spyOn(this.chatboxviews, 'trimChats');
|
spyOn(this.chatboxviews, 'trimChats');
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openChatBoxes(6);
|
test_utils.openChatBoxes(6);
|
||||||
expect(this.chatboxviews.trimChats).toHaveBeenCalled();
|
expect(this.chatboxviews.trimChats).toHaveBeenCalled();
|
||||||
// We instantiate a new ChatBoxes collection, which by default
|
// We instantiate a new ChatBoxes collection, which by default
|
||||||
// will be empty.
|
// will be empty.
|
||||||
@ -136,7 +136,7 @@
|
|||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("can be closed by clicking a DOM element with class 'close-chatbox-button'", $.proxy(function () {
|
it("can be closed by clicking a DOM element with class 'close-chatbox-button'", $.proxy(function () {
|
||||||
var chatbox = utils.openChatBoxes(1)[0],
|
var chatbox = test_utils.openChatBoxes(1)[0],
|
||||||
controlview = this.chatboxviews.get('controlbox'), // The controlbox is currently open
|
controlview = this.chatboxviews.get('controlbox'), // The controlbox is currently open
|
||||||
chatview = this.chatboxviews.get(chatbox.get('jid'));
|
chatview = this.chatboxviews.get(chatbox.get('jid'));
|
||||||
spyOn(chatview, 'close').andCallThrough();
|
spyOn(chatview, 'close').andCallThrough();
|
||||||
@ -166,7 +166,7 @@
|
|||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("can be minimized by clicking a DOM element with class 'toggle-chatbox-button'", function () {
|
it("can be minimized by clicking a DOM element with class 'toggle-chatbox-button'", function () {
|
||||||
var chatbox = utils.openChatBoxes(1)[0],
|
var chatbox = test_utils.openChatBoxes(1)[0],
|
||||||
chatview = this.chatboxviews.get(chatbox.get('jid')),
|
chatview = this.chatboxviews.get(chatbox.get('jid')),
|
||||||
trimmed_chatboxes = this.minimized_chats,
|
trimmed_chatboxes = this.minimized_chats,
|
||||||
trimmedview;
|
trimmedview;
|
||||||
@ -207,17 +207,17 @@
|
|||||||
spyOn(converse.chatboxviews, 'trimChats');
|
spyOn(converse.chatboxviews, 'trimChats');
|
||||||
this.chatboxes.browserStorage._clear();
|
this.chatboxes.browserStorage._clear();
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.closeControlBox();
|
test_utils.closeControlBox();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
expect(converse.emit).toHaveBeenCalledWith('chatBoxClosed', 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);
|
test_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('chatBoxOpened', jasmine.any(Object));
|
expect(converse.emit).toHaveBeenCalledWith('chatBoxOpened', jasmine.any(Object));
|
||||||
utils.closeAllChatBoxes();
|
test_utils.closeAllChatBoxes();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
@ -237,7 +237,7 @@
|
|||||||
describe("A chat toolbar", $.proxy(function () {
|
describe("A chat toolbar", $.proxy(function () {
|
||||||
it("can be found on each chat box", $.proxy(function () {
|
it("can be found on each chat box", $.proxy(function () {
|
||||||
var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var chatbox = this.chatboxes.get(contact_jid);
|
var chatbox = this.chatboxes.get(contact_jid);
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var view = this.chatboxviews.get(contact_jid);
|
||||||
expect(chatbox).toBeDefined();
|
expect(chatbox).toBeDefined();
|
||||||
@ -249,7 +249,7 @@
|
|||||||
|
|
||||||
it("contains a button for inserting emoticons", $.proxy(function () {
|
it("contains a button for inserting emoticons", $.proxy(function () {
|
||||||
var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var view = this.chatboxviews.get(contact_jid);
|
||||||
var $toolbar = view.$el.find('ul.chat-toolbar');
|
var $toolbar = view.$el.find('ul.chat-toolbar');
|
||||||
var $textarea = view.$el.find('textarea.chat-textarea');
|
var $textarea = view.$el.find('textarea.chat-textarea');
|
||||||
@ -308,7 +308,7 @@
|
|||||||
it("contains a button for starting an encrypted chat session", $.proxy(function () {
|
it("contains a button for starting an encrypted chat session", $.proxy(function () {
|
||||||
// TODO: More tests can be added here...
|
// TODO: More tests can be added here...
|
||||||
var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[2].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var view = this.chatboxviews.get(contact_jid);
|
||||||
var $toolbar = view.$el.find('ul.chat-toolbar');
|
var $toolbar = view.$el.find('ul.chat-toolbar');
|
||||||
expect($toolbar.children('li.toggle-otr').length).toBe(1);
|
expect($toolbar.children('li.toggle-otr').length).toBe(1);
|
||||||
@ -336,7 +336,7 @@
|
|||||||
// First check that the button doesn't show if it's not enabled
|
// First check that the button doesn't show if it's not enabled
|
||||||
// via "visible_toolbar_buttons"
|
// via "visible_toolbar_buttons"
|
||||||
converse.visible_toolbar_buttons.call = false;
|
converse.visible_toolbar_buttons.call = false;
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
view = this.chatboxviews.get(contact_jid);
|
view = this.chatboxviews.get(contact_jid);
|
||||||
$toolbar = view.$el.find('ul.chat-toolbar');
|
$toolbar = view.$el.find('ul.chat-toolbar');
|
||||||
callButton = $toolbar.find('.toggle-call');
|
callButton = $toolbar.find('.toggle-call');
|
||||||
@ -345,7 +345,7 @@
|
|||||||
// Now check that it's shown if enabled and that it emits
|
// Now check that it's shown if enabled and that it emits
|
||||||
// callButtonClicked
|
// callButtonClicked
|
||||||
converse.visible_toolbar_buttons.call = true; // enable the button
|
converse.visible_toolbar_buttons.call = true; // enable the button
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
view = this.chatboxviews.get(contact_jid);
|
view = this.chatboxviews.get(contact_jid);
|
||||||
$toolbar = view.$el.find('ul.chat-toolbar');
|
$toolbar = view.$el.find('ul.chat-toolbar');
|
||||||
callButton = $toolbar.find('.toggle-call');
|
callButton = $toolbar.find('.toggle-call');
|
||||||
@ -360,7 +360,7 @@
|
|||||||
// First check that the button doesn't show if it's not enabled
|
// First check that the button doesn't show if it's not enabled
|
||||||
// via "visible_toolbar_buttons"
|
// via "visible_toolbar_buttons"
|
||||||
converse.visible_toolbar_buttons.clear = false;
|
converse.visible_toolbar_buttons.clear = false;
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
view = this.chatboxviews.get(contact_jid);
|
view = this.chatboxviews.get(contact_jid);
|
||||||
view = this.chatboxviews.get(contact_jid);
|
view = this.chatboxviews.get(contact_jid);
|
||||||
$toolbar = view.$el.find('ul.chat-toolbar');
|
$toolbar = view.$el.find('ul.chat-toolbar');
|
||||||
@ -370,7 +370,7 @@
|
|||||||
// Now check that it's shown if enabled and that it calls
|
// Now check that it's shown if enabled and that it calls
|
||||||
// clearMessages
|
// clearMessages
|
||||||
converse.visible_toolbar_buttons.clear = true; // enable the button
|
converse.visible_toolbar_buttons.clear = true; // enable the button
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
view = this.chatboxviews.get(contact_jid);
|
view = this.chatboxviews.get(contact_jid);
|
||||||
$toolbar = view.$el.find('ul.chat-toolbar');
|
$toolbar = view.$el.find('ul.chat-toolbar');
|
||||||
clearButton = $toolbar.find('.toggle-clear');
|
clearButton = $toolbar.find('.toggle-clear');
|
||||||
@ -387,7 +387,7 @@
|
|||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.closeAllChatBoxes();
|
test_utils.closeAllChatBoxes();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {});
|
runs(function () {});
|
||||||
@ -445,7 +445,7 @@
|
|||||||
var contact_jid = contact_name.replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = contact_name.replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
spyOn(this, 'emit');
|
spyOn(this, 'emit');
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var chatview = converse.chatboxviews.get(contact_jid);
|
var chatview = converse.chatboxviews.get(contact_jid);
|
||||||
expect(chatview.model.get('minimized')).toBeFalsy();
|
expect(chatview.model.get('minimized')).toBeFalsy();
|
||||||
chatview.$el.find('.toggle-chatbox-button').click();
|
chatview.$el.find('.toggle-chatbox-button').click();
|
||||||
@ -505,8 +505,8 @@
|
|||||||
spyOn(converse, 'emit');
|
spyOn(converse, 'emit');
|
||||||
var contact_name = mock.cur_names[1];
|
var contact_name = mock.cur_names[1];
|
||||||
var contact_jid = contact_name.replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = contact_name.replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
utils.clearChatBoxMessages(contact_jid);
|
test_utils.clearChatBoxMessages(contact_jid);
|
||||||
var one_day_ago = moment();
|
var one_day_ago = moment();
|
||||||
one_day_ago.subtract('days', 1);
|
one_day_ago.subtract('days', 1);
|
||||||
var message = 'This is a day old message';
|
var message = 'This is a day old message';
|
||||||
@ -574,7 +574,7 @@
|
|||||||
spyOn(converse, 'emit');
|
spyOn(converse, 'emit');
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
@ -582,7 +582,7 @@
|
|||||||
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);
|
test_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, ['messageSend', message]);
|
expect(converse.emit.mostRecentCall.args, ['messageSend', message]);
|
||||||
@ -592,11 +592,11 @@
|
|||||||
|
|
||||||
it("is sanitized to prevent Javascript injection attacks", $.proxy(function () {
|
it("is sanitized to prevent Javascript injection attacks", $.proxy(function () {
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var view = this.chatboxviews.get(contact_jid);
|
||||||
var message = '<p>This message contains <em>some</em> <b>markup</b></p>';
|
var message = '<p>This message contains <em>some</em> <b>markup</b></p>';
|
||||||
spyOn(view, 'sendMessage').andCallThrough();
|
spyOn(view, 'sendMessage').andCallThrough();
|
||||||
utils.sendMessage(view, message);
|
test_utils.sendMessage(view, message);
|
||||||
expect(view.sendMessage).toHaveBeenCalled();
|
expect(view.sendMessage).toHaveBeenCalled();
|
||||||
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
||||||
expect(msg.text()).toEqual(message);
|
expect(msg.text()).toEqual(message);
|
||||||
@ -605,11 +605,11 @@
|
|||||||
|
|
||||||
it("can contain hyperlinks, which will be clickable", $.proxy(function () {
|
it("can contain hyperlinks, which will be clickable", $.proxy(function () {
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var view = this.chatboxviews.get(contact_jid);
|
||||||
var message = 'This message contains a hyperlink: www.opkode.com';
|
var message = 'This message contains a hyperlink: www.opkode.com';
|
||||||
spyOn(view, 'sendMessage').andCallThrough();
|
spyOn(view, 'sendMessage').andCallThrough();
|
||||||
utils.sendMessage(view, message);
|
test_utils.sendMessage(view, message);
|
||||||
expect(view.sendMessage).toHaveBeenCalled();
|
expect(view.sendMessage).toHaveBeenCalled();
|
||||||
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
||||||
expect(msg.text()).toEqual(message);
|
expect(msg.text()).toEqual(message);
|
||||||
@ -618,7 +618,7 @@
|
|||||||
|
|
||||||
it("should display emoticons correctly", $.proxy(function () {
|
it("should display emoticons correctly", $.proxy(function () {
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var view = this.chatboxviews.get(contact_jid);
|
||||||
var messages = [':)', ';)', ':D', ':P', '8)', '>:)', ':S', ':\\', '>:(', ':(', ':O', '(^.^)b', '<3'];
|
var messages = [':)', ';)', ':D', ':P', '8)', '>:)', ':S', ':\\', '>:(', ':(', ':O', '(^.^)b', '<3'];
|
||||||
var emoticons = [
|
var emoticons = [
|
||||||
@ -633,7 +633,7 @@
|
|||||||
spyOn(view, 'sendMessage').andCallThrough();
|
spyOn(view, 'sendMessage').andCallThrough();
|
||||||
for (var i = 0; i < messages.length; i++) {
|
for (var i = 0; i < messages.length; i++) {
|
||||||
var message = messages[i];
|
var message = messages[i];
|
||||||
utils.sendMessage(view, message);
|
test_utils.sendMessage(view, message);
|
||||||
expect(view.sendMessage).toHaveBeenCalled();
|
expect(view.sendMessage).toHaveBeenCalled();
|
||||||
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
||||||
expect(msg.html()).toEqual(emoticons[i]);
|
expect(msg.html()).toEqual(emoticons[i]);
|
||||||
@ -642,33 +642,33 @@
|
|||||||
|
|
||||||
it("will have properly escaped URLs", $.proxy(function () {
|
it("will have properly escaped URLs", $.proxy(function () {
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var view = this.chatboxviews.get(contact_jid);
|
||||||
spyOn(view, 'sendMessage').andCallThrough();
|
spyOn(view, 'sendMessage').andCallThrough();
|
||||||
|
|
||||||
var message = "http://www.opkode.com/'onmouseover='alert(1)'whatever";
|
var message = "http://www.opkode.com/'onmouseover='alert(1)'whatever";
|
||||||
utils.sendMessage(view, message);
|
test_utils.sendMessage(view, message);
|
||||||
expect(view.sendMessage).toHaveBeenCalled();
|
expect(view.sendMessage).toHaveBeenCalled();
|
||||||
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
var msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
||||||
expect(msg.text()).toEqual(message);
|
expect(msg.text()).toEqual(message);
|
||||||
expect(msg.html()).toEqual('<a target="_blank" href="http://www.opkode.com/%27onmouseover=%27alert%281%29%27whatever">http://www.opkode.com/\'onmouseover=\'alert(1)\'whatever</a>');
|
expect(msg.html()).toEqual('<a target="_blank" href="http://www.opkode.com/%27onmouseover=%27alert%281%29%27whatever">http://www.opkode.com/\'onmouseover=\'alert(1)\'whatever</a>');
|
||||||
|
|
||||||
message = 'http://www.opkode.com/"onmouseover="alert(1)"whatever';
|
message = 'http://www.opkode.com/"onmouseover="alert(1)"whatever';
|
||||||
utils.sendMessage(view, message);
|
test_utils.sendMessage(view, message);
|
||||||
expect(view.sendMessage).toHaveBeenCalled();
|
expect(view.sendMessage).toHaveBeenCalled();
|
||||||
msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
||||||
expect(msg.text()).toEqual(message);
|
expect(msg.text()).toEqual(message);
|
||||||
expect(msg.html()).toEqual('<a target="_blank" href="http://www.opkode.com/%22onmouseover=%22alert%281%29%22whatever">http://www.opkode.com/"onmouseover="alert(1)"whatever</a>');
|
expect(msg.html()).toEqual('<a target="_blank" href="http://www.opkode.com/%22onmouseover=%22alert%281%29%22whatever">http://www.opkode.com/"onmouseover="alert(1)"whatever</a>');
|
||||||
|
|
||||||
message = "https://en.wikipedia.org/wiki/Ender's_Game";
|
message = "https://en.wikipedia.org/wiki/Ender's_Game";
|
||||||
utils.sendMessage(view, message);
|
test_utils.sendMessage(view, message);
|
||||||
expect(view.sendMessage).toHaveBeenCalled();
|
expect(view.sendMessage).toHaveBeenCalled();
|
||||||
msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
||||||
expect(msg.text()).toEqual(message);
|
expect(msg.text()).toEqual(message);
|
||||||
expect(msg.html()).toEqual('<a target="_blank" href="https://en.wikipedia.org/wiki/Ender%27s_Game">https://en.wikipedia.org/wiki/Ender\'s_Game</a>');
|
expect(msg.html()).toEqual('<a target="_blank" href="https://en.wikipedia.org/wiki/Ender%27s_Game">https://en.wikipedia.org/wiki/Ender\'s_Game</a>');
|
||||||
|
|
||||||
message = "https://en.wikipedia.org/wiki/Ender%27s_Game";
|
message = "https://en.wikipedia.org/wiki/Ender%27s_Game";
|
||||||
utils.sendMessage(view, message);
|
test_utils.sendMessage(view, message);
|
||||||
expect(view.sendMessage).toHaveBeenCalled();
|
expect(view.sendMessage).toHaveBeenCalled();
|
||||||
msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
msg = view.$el.find('.chat-content').find('.chat-message').last().find('.chat-message-content');
|
||||||
expect(msg.text()).toEqual(message);
|
expect(msg.text()).toEqual(message);
|
||||||
@ -680,24 +680,24 @@
|
|||||||
|
|
||||||
describe("Special Messages", $.proxy(function () {
|
describe("Special Messages", $.proxy(function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
utils.closeAllChatBoxes();
|
test_utils.closeAllChatBoxes();
|
||||||
utils.removeControlBox();
|
test_utils.removeControlBox();
|
||||||
converse.roster.browserStorage._clear();
|
converse.roster.browserStorage._clear();
|
||||||
utils.initConverse();
|
test_utils.initConverse();
|
||||||
utils.createContacts();
|
test_utils.createContacts();
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
utils.openContactsPanel();
|
test_utils.openContactsPanel();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("'/clear' can be used to clear messages in a conversation", $.proxy(function () {
|
it("'/clear' can be used to clear messages in a conversation", $.proxy(function () {
|
||||||
spyOn(converse, 'emit');
|
spyOn(converse, 'emit');
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var view = this.chatboxviews.get(contact_jid);
|
var view = this.chatboxviews.get(contact_jid);
|
||||||
var message = 'This message is another sent from this chatbox';
|
var message = 'This message is another sent from this chatbox';
|
||||||
// Lets make sure there is at least one message already
|
// Lets make sure there is at least one message already
|
||||||
// (e.g for when this test is run on its own).
|
// (e.g for when this test is run on its own).
|
||||||
utils.sendMessage(view, message);
|
test_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('messageSend', message);
|
expect(converse.emit).toHaveBeenCalledWith('messageSend', message);
|
||||||
@ -709,7 +709,7 @@
|
|||||||
spyOn(window, 'confirm').andCallFake(function () {
|
spyOn(window, 'confirm').andCallFake(function () {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
utils.sendMessage(view, message);
|
test_utils.sendMessage(view, message);
|
||||||
expect(view.sendMessage).toHaveBeenCalled();
|
expect(view.sendMessage).toHaveBeenCalled();
|
||||||
expect(view.clearMessages).toHaveBeenCalled();
|
expect(view.clearMessages).toHaveBeenCalled();
|
||||||
expect(window.confirm).toHaveBeenCalled();
|
expect(window.confirm).toHaveBeenCalled();
|
||||||
@ -775,5 +775,5 @@
|
|||||||
expect(this.msg_counter).toBe(0);
|
expect(this.msg_counter).toBe(0);
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
}));
|
}));
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([
|
define([
|
||||||
"mock",
|
"mock",
|
||||||
"utils"
|
"test_utils"
|
||||||
], function (mock, utils) {
|
], function (mock, test_utils) {
|
||||||
return factory(mock, utils);
|
return factory(mock, test_utils);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} (this, function (mock, utils) {
|
} (this, function (mock, test_utils) {
|
||||||
return describe("ChatRooms", $.proxy(function (mock, utils) {
|
return describe("ChatRooms", $.proxy(function (mock, test_utils) {
|
||||||
describe("A Chat Room", $.proxy(function () {
|
describe("A Chat Room", $.proxy(function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.closeAllChatBoxes();
|
test_utils.closeAllChatBoxes();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openRoomsPanel();
|
test_utils.openRoomsPanel();
|
||||||
});
|
});
|
||||||
waits(501);
|
waits(501);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
@ -35,7 +35,7 @@
|
|||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.closeControlBox();
|
test_utils.closeControlBox();
|
||||||
});
|
});
|
||||||
waits(250);
|
waits(250);
|
||||||
runs(function () {});
|
runs(function () {});
|
||||||
@ -116,7 +116,7 @@
|
|||||||
// We instantiate a new ChatBoxes collection, which by default
|
// We instantiate a new ChatBoxes collection, which by default
|
||||||
// will be empty.
|
// will be empty.
|
||||||
spyOn(this.chatboxviews, 'trimChats');
|
spyOn(this.chatboxviews, 'trimChats');
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
var newchatboxes = new this.ChatBoxes();
|
var newchatboxes = new this.ChatBoxes();
|
||||||
expect(newchatboxes.length).toEqual(0);
|
expect(newchatboxes.length).toEqual(0);
|
||||||
// The chatboxes will then be fetched from browserStorage inside the
|
// The chatboxes will then be fetched from browserStorage inside the
|
||||||
@ -350,5 +350,5 @@
|
|||||||
expect(view.$el.find('.chat-body p').text()).toBe("This room has reached it's maximum number of occupants");
|
expect(view.$el.find('.chat-body p').text()).toBe("This room has reached it's maximum number of occupants");
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
}));
|
}));
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([
|
define([
|
||||||
"mock",
|
"mock",
|
||||||
"utils"
|
"test_utils"
|
||||||
], function (mock, utils) {
|
], function (mock, test_utils) {
|
||||||
return factory(mock, utils);
|
return factory(mock, test_utils);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} (this, function (mock, utils) {
|
} (this, function (mock, test_utils) {
|
||||||
|
|
||||||
var checkHeaderToggling = function ($header) {
|
var checkHeaderToggling = function ($header) {
|
||||||
var $toggle = $header.find('a.group-toggle');
|
var $toggle = $header.find('a.group-toggle');
|
||||||
@ -24,16 +24,16 @@
|
|||||||
expect($header.nextUntil('dt', 'dd').length === $header.nextUntil('dt', 'dd:visible').length).toBeTruthy();
|
expect($header.nextUntil('dt', 'dd').length === $header.nextUntil('dt', 'dd:visible').length).toBeTruthy();
|
||||||
};
|
};
|
||||||
|
|
||||||
describe("The Control Box", $.proxy(function (mock, utils) {
|
describe("The Control Box", $.proxy(function (mock, test_utils) {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can be opened by clicking a DOM element with class 'toggle-controlbox'", $.proxy(function () {
|
it("can be opened by clicking a DOM element with class 'toggle-controlbox'", $.proxy(function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.closeControlBox();
|
test_utils.closeControlBox();
|
||||||
});
|
});
|
||||||
waits(50);
|
waits(50);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
@ -59,7 +59,7 @@
|
|||||||
describe("The Status Widget", $.proxy(function () {
|
describe("The Status Widget", $.proxy(function () {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows the user's chat status, which is online by default", $.proxy(function () {
|
it("shows the user's chat status, which is online by default", $.proxy(function () {
|
||||||
@ -120,9 +120,9 @@
|
|||||||
});
|
});
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
|
|
||||||
describe("The Contacts Roster", $.proxy(function (mock, utils) {
|
describe("The Contacts Roster", $.proxy(function (mock, test_utils) {
|
||||||
|
|
||||||
describe("A Roster Group", $.proxy(function () {
|
describe("A Roster Group", $.proxy(function () {
|
||||||
|
|
||||||
@ -135,7 +135,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function _clearContacts () {
|
function _clearContacts () {
|
||||||
utils.clearBrowserStorage();
|
test_utils.clearBrowserStorage();
|
||||||
converse.rosterview.model.reset();
|
converse.rosterview.model.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,8 +146,8 @@
|
|||||||
spyOn(this.rosterview, 'update').andCallThrough();
|
spyOn(this.rosterview, 'update').andCallThrough();
|
||||||
converse.rosterview.render();
|
converse.rosterview.render();
|
||||||
|
|
||||||
utils.createContacts('pending');
|
test_utils.createContacts('pending');
|
||||||
utils.createContacts('requesting');
|
test_utils.createContacts('requesting');
|
||||||
var groups = {
|
var groups = {
|
||||||
'colleagues': 3,
|
'colleagues': 3,
|
||||||
'friends & acquaintences': 3,
|
'friends & acquaintences': 3,
|
||||||
@ -243,14 +243,14 @@
|
|||||||
|
|
||||||
describe("Pending Contacts", $.proxy(function () {
|
describe("Pending Contacts", $.proxy(function () {
|
||||||
function _clearContacts () {
|
function _clearContacts () {
|
||||||
utils.clearBrowserStorage();
|
test_utils.clearBrowserStorage();
|
||||||
converse.rosterview.model.reset();
|
converse.rosterview.model.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
function _addContacts () {
|
function _addContacts () {
|
||||||
_clearContacts();
|
_clearContacts();
|
||||||
// Must be initialized, so that render is called and documentFragment set up.
|
// Must be initialized, so that render is called and documentFragment set up.
|
||||||
utils.createContacts('pending').openControlBox().openContactsPanel();
|
test_utils.createContacts('pending').openControlBox().openContactsPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
it("can be collapsed under their own header", $.proxy(function () {
|
it("can be collapsed under their own header", $.proxy(function () {
|
||||||
@ -350,13 +350,13 @@
|
|||||||
|
|
||||||
describe("Existing Contacts", $.proxy(function () {
|
describe("Existing Contacts", $.proxy(function () {
|
||||||
function _clearContacts () {
|
function _clearContacts () {
|
||||||
utils.clearBrowserStorage();
|
test_utils.clearBrowserStorage();
|
||||||
converse.rosterview.model.reset();
|
converse.rosterview.model.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
var _addContacts = function () {
|
var _addContacts = function () {
|
||||||
_clearContacts();
|
_clearContacts();
|
||||||
utils.createContacts().openControlBox().openContactsPanel();
|
test_utils.createContacts().openControlBox().openContactsPanel();
|
||||||
};
|
};
|
||||||
|
|
||||||
it("can be collapsed under their own header", $.proxy(function () {
|
it("can be collapsed under their own header", $.proxy(function () {
|
||||||
@ -561,13 +561,13 @@
|
|||||||
describe("Requesting Contacts", $.proxy(function () {
|
describe("Requesting Contacts", $.proxy(function () {
|
||||||
beforeEach($.proxy(function () {
|
beforeEach($.proxy(function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.clearBrowserStorage();
|
test_utils.clearBrowserStorage();
|
||||||
converse.rosterview.model.reset();
|
converse.rosterview.model.reset();
|
||||||
utils.createContacts('requesting').openControlBox();
|
test_utils.createContacts('requesting').openControlBox();
|
||||||
});
|
});
|
||||||
waits(50);
|
waits(50);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openContactsPanel();
|
test_utils.openContactsPanel();
|
||||||
});
|
});
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
@ -646,7 +646,7 @@
|
|||||||
spyOn(converse, 'emit');
|
spyOn(converse, 'emit');
|
||||||
spyOn(this.connection.roster, 'unauthorize');
|
spyOn(this.connection.roster, 'unauthorize');
|
||||||
spyOn(window, 'confirm').andReturn(true);
|
spyOn(window, 'confirm').andReturn(true);
|
||||||
utils.createContacts('requesting').openControlBox();
|
test_utils.createContacts('requesting').openControlBox();
|
||||||
var name = mock.req_names.sort()[1];
|
var name = mock.req_names.sort()[1];
|
||||||
var jid = name.replace(/ /g,'.').toLowerCase() + '@localhost';
|
var jid = name.replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
converse.rosterview.$el.find(".req-contact-name:contains('"+name+"')")
|
converse.rosterview.$el.find(".req-contact-name:contains('"+name+"')")
|
||||||
@ -661,10 +661,10 @@
|
|||||||
|
|
||||||
describe("All Contacts", $.proxy(function () {
|
describe("All Contacts", $.proxy(function () {
|
||||||
beforeEach($.proxy(function () {
|
beforeEach($.proxy(function () {
|
||||||
utils.clearBrowserStorage();
|
test_utils.clearBrowserStorage();
|
||||||
converse.rosterview.model.reset();
|
converse.rosterview.model.reset();
|
||||||
utils.createContacts('all').openControlBox();
|
test_utils.createContacts('all').openControlBox();
|
||||||
utils.openContactsPanel();
|
test_utils.openContactsPanel();
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
it("are saved to, and can be retrieved from, browserStorage", $.proxy(function () {
|
it("are saved to, and can be retrieved from, browserStorage", $.proxy(function () {
|
||||||
@ -700,9 +700,9 @@
|
|||||||
}
|
}
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
|
|
||||||
describe("The 'Add Contact' widget", $.proxy(function (mock, utils) {
|
describe("The 'Add Contact' widget", $.proxy(function (mock, test_utils) {
|
||||||
it("opens up an add form when you click on it", $.proxy(function () {
|
it("opens up an add form when you click on it", $.proxy(function () {
|
||||||
var panel = this.chatboxviews.get('controlbox').contactspanel;
|
var panel = this.chatboxviews.get('controlbox').contactspanel;
|
||||||
spyOn(panel, 'toggleContactForm').andCallThrough();
|
spyOn(panel, 'toggleContactForm').andCallThrough();
|
||||||
@ -713,16 +713,16 @@
|
|||||||
panel.$el.find('a.toggle-xmpp-contact-form').click();
|
panel.$el.find('a.toggle-xmpp-contact-form').click();
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
|
|
||||||
describe("The Controlbox Tabs", $.proxy(function () {
|
describe("The Controlbox Tabs", $.proxy(function () {
|
||||||
beforeEach($.proxy(function () {
|
beforeEach($.proxy(function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.closeAllChatBoxes();
|
test_utils.closeAllChatBoxes();
|
||||||
});
|
});
|
||||||
waits(50);
|
waits(50);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
});
|
});
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
@ -739,11 +739,11 @@
|
|||||||
describe("chatrooms panel", $.proxy(function () {
|
describe("chatrooms panel", $.proxy(function () {
|
||||||
beforeEach($.proxy(function () {
|
beforeEach($.proxy(function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.closeAllChatBoxes();
|
test_utils.closeAllChatBoxes();
|
||||||
});
|
});
|
||||||
waits(50);
|
waits(50);
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
});
|
});
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
@ -792,5 +792,5 @@
|
|||||||
}, converse));
|
}, converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
}));
|
}));
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([
|
define([
|
||||||
"mock",
|
"mock",
|
||||||
"utils"
|
"test_utils"
|
||||||
], function (mock, utils) {
|
], function (mock, test_utils) {
|
||||||
return factory(mock, utils);
|
return factory(mock, test_utils);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} (this, function (mock, utils) {
|
} (this, function (mock, test_utils) {
|
||||||
return describe("Converse", $.proxy(function(mock, utils) {
|
return describe("Converse", $.proxy(function(mock, test_utils) {
|
||||||
|
|
||||||
beforeEach($.proxy(function () {
|
beforeEach($.proxy(function () {
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
@ -43,5 +43,5 @@
|
|||||||
// Restore the connection
|
// Restore the connection
|
||||||
converse.connection = old_connection;
|
converse.connection = old_connection;
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
}));
|
}));
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([
|
define([
|
||||||
"mock",
|
"mock",
|
||||||
"utils"
|
"test_utils"
|
||||||
], function (mock, utils) {
|
], function (mock, test_utils) {
|
||||||
return factory(mock, utils);
|
return factory(mock, test_utils);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} (this, function (mock, utils) {
|
} (this, function (mock, test_utils) {
|
||||||
return describe("The Converse Event Emitter", $.proxy(function(mock, utils) {
|
return describe("The Converse Event Emitter", $.proxy(function(mock, test_utils) {
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
window.sessionStorage.clear();
|
window.sessionStorage.clear();
|
||||||
|
|
||||||
@ -64,5 +64,5 @@
|
|||||||
expect(this.anotherCallback.callCount, 3);
|
expect(this.anotherCallback.callCount, 3);
|
||||||
expect(this.neverCalled).not.toHaveBeenCalled();
|
expect(this.neverCalled).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
}));
|
}));
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([
|
define([
|
||||||
"mock",
|
"mock",
|
||||||
"utils"
|
"test_utils"
|
||||||
], function (mock, utils) {
|
], function (mock, test_utils) {
|
||||||
return factory(mock, utils);
|
return factory(mock, test_utils);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} (this, function (mock, utils) {
|
} (this, function (mock, test_utils) {
|
||||||
return describe("The Minimized Chats Widget", $.proxy(function(mock, utils) {
|
return describe("The Minimized Chats Widget", $.proxy(function(mock, test_utils) {
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
runs(function () {
|
runs(function () {
|
||||||
utils.closeAllChatBoxes();
|
test_utils.closeAllChatBoxes();
|
||||||
utils.removeControlBox();
|
test_utils.removeControlBox();
|
||||||
converse.roster.browserStorage._clear();
|
converse.roster.browserStorage._clear();
|
||||||
utils.initConverse();
|
test_utils.initConverse();
|
||||||
utils.createContacts();
|
test_utils.createContacts();
|
||||||
utils.openControlBox();
|
test_utils.openControlBox();
|
||||||
utils.openContactsPanel();
|
test_utils.openContactsPanel();
|
||||||
converse.minimized_chats.toggleview.model.browserStorage._clear();
|
converse.minimized_chats.toggleview.model.browserStorage._clear();
|
||||||
converse.minimized_chats.initToggle();
|
converse.minimized_chats.initToggle();
|
||||||
});
|
});
|
||||||
@ -26,7 +26,7 @@
|
|||||||
it("shows chats that have been minimized", $.proxy(function () {
|
it("shows chats that have been minimized", $.proxy(function () {
|
||||||
var contact_jid, chatview;
|
var contact_jid, chatview;
|
||||||
contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
chatview = converse.chatboxviews.get(contact_jid);
|
chatview = converse.chatboxviews.get(contact_jid);
|
||||||
expect(chatview.model.get('minimized')).toBeFalsy();
|
expect(chatview.model.get('minimized')).toBeFalsy();
|
||||||
expect(this.minimized_chats.$el.is(':visible')).toBeFalsy();
|
expect(this.minimized_chats.$el.is(':visible')).toBeFalsy();
|
||||||
@ -37,7 +37,7 @@
|
|||||||
expect(this.minimized_chats.keys()[0]).toBe(contact_jid);
|
expect(this.minimized_chats.keys()[0]).toBe(contact_jid);
|
||||||
|
|
||||||
contact_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
|
contact_jid = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
chatview = converse.chatboxviews.get(contact_jid);
|
chatview = converse.chatboxviews.get(contact_jid);
|
||||||
expect(chatview.model.get('minimized')).toBeFalsy();
|
expect(chatview.model.get('minimized')).toBeFalsy();
|
||||||
chatview.$el.find('.toggle-chatbox-button').click();
|
chatview.$el.find('.toggle-chatbox-button').click();
|
||||||
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
it("can be toggled to hide or show minimized chats", $.proxy(function () {
|
it("can be toggled to hide or show minimized chats", $.proxy(function () {
|
||||||
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
var contact_jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
var chatview = converse.chatboxviews.get(contact_jid);
|
var chatview = converse.chatboxviews.get(contact_jid);
|
||||||
expect(this.minimized_chats.$el.is(':visible')).toBeFalsy();
|
expect(this.minimized_chats.$el.is(':visible')).toBeFalsy();
|
||||||
chatview.model.set({'minimized': true});
|
chatview.model.set({'minimized': true});
|
||||||
@ -70,7 +70,7 @@
|
|||||||
expect(this.minimized_chats.toggleview.$('.unread-message-count').is(':visible')).toBeFalsy();
|
expect(this.minimized_chats.toggleview.$('.unread-message-count').is(':visible')).toBeFalsy();
|
||||||
for (i=0; i<3; i++) {
|
for (i=0; i<3; i++) {
|
||||||
contact_jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
|
contact_jid = mock.cur_names[i].replace(/ /g,'.').toLowerCase() + '@localhost';
|
||||||
utils.openChatBoxFor(contact_jid);
|
test_utils.openChatBoxFor(contact_jid);
|
||||||
chatview = converse.chatboxviews.get(contact_jid);
|
chatview = converse.chatboxviews.get(contact_jid);
|
||||||
chatview.model.set({'minimized': true});
|
chatview.model.set({'minimized': true});
|
||||||
msg = $msg({
|
msg = $msg({
|
||||||
@ -86,5 +86,5 @@
|
|||||||
}
|
}
|
||||||
}, converse));
|
}, converse));
|
||||||
|
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
}));
|
}));
|
||||||
|
12
spec/otr.js
12
spec/otr.js
@ -1,13 +1,13 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define([
|
define([
|
||||||
"mock",
|
"mock",
|
||||||
"utils"
|
"test_utils"
|
||||||
], function (mock, utils) {
|
], function (mock, test_utils) {
|
||||||
return factory(mock, utils);
|
return factory(mock, test_utils);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} (this, function (mock, utils) {
|
} (this, function (mock, test_utils) {
|
||||||
return describe("The OTR module", $.proxy(function(mock, utils) {
|
return describe("The OTR module", $.proxy(function(mock, test_utils) {
|
||||||
|
|
||||||
beforeEach($.proxy(function () {
|
beforeEach($.proxy(function () {
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
@ -36,5 +36,5 @@
|
|||||||
// Clean up
|
// Clean up
|
||||||
this.prebind = false;
|
this.prebind = false;
|
||||||
}, converse));
|
}, converse));
|
||||||
}, converse, mock, utils));
|
}, converse, mock, test_utils));
|
||||||
}));
|
}));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Extra test dependencies
|
// Extra test dependencies
|
||||||
config.paths.mock = "tests/mock";
|
config.paths.mock = "tests/mock";
|
||||||
config.paths.utils = "tests/utils";
|
config.paths.test_utils = "tests/utils";
|
||||||
config.paths.jasmine = "components/jasmine/lib/jasmine-core/jasmine";
|
config.paths.jasmine = "components/jasmine/lib/jasmine-core/jasmine";
|
||||||
config.paths["jasmine-html"] = "components/jasmine/lib/jasmine-core/jasmine-html";
|
config.paths["jasmine-html"] = "components/jasmine/lib/jasmine-core/jasmine-html";
|
||||||
config.paths["console-runner"] = "node_modules/phantom-jasmine/lib/console-runner";
|
config.paths["console-runner"] = "node_modules/phantom-jasmine/lib/console-runner";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
define("utils", [
|
define("test_utils", [
|
||||||
'jquery',
|
'jquery',
|
||||||
'mock'
|
'mock'
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user