Commit 16d62bf9 authored by JC Brand's avatar JC Brand

Fix broken tests due to using ES2015 promises

parent e75b6ad6
......@@ -17,7 +17,9 @@
describe("A chat room", function () {
it("can be bookmarked", mock.initConverse(function (_converse) {
it("can be bookmarked", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {}, function (done, _converse) {
var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ;
spyOn(_converse.connection, 'sendIQ').and.callFake(function (iq, callback, errback) {
......@@ -124,9 +126,12 @@
_converse.connection._dataRecv(test_utils.createRequest(stanza));
// We ignore this IQ stanza... (unless it's an error stanza), so
// nothing to test for here.
done();
}));
it("will be automatically opened if 'autojoin' is set on the bookmark", mock.initConverse(function (_converse) {
it("will be automatically opened if 'autojoin' is set on the bookmark", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {}, function (done, _converse) {
var jid = 'lounge@localhost';
_converse.bookmarks.create({
'jid': jid,
......@@ -144,11 +149,14 @@
'nick': ' Othello'
});
expect(_.isUndefined(_converse.chatboxviews.get(jid))).toBeFalsy();
done();
}));
describe("when bookmarked", function () {
it("displays that it's bookmarked through its bookmark icon", mock.initConverse(function (_converse) {
it("displays that it's bookmarked through its bookmark icon", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {}, function (done, _converse) {
test_utils.openChatRoom(_converse, 'lounge', 'localhost', 'dummy');
var view = _converse.chatboxviews.get('lounge@localhost');
var $bookmark_icon = view.$('.icon-pushpin');
......@@ -157,9 +165,12 @@
expect($bookmark_icon.hasClass('button-on')).toBeTruthy();
view.model.set('bookmarked', false);
expect($bookmark_icon.hasClass('button-on')).toBeFalsy();
done();
}));
it("can be unbookmarked", mock.initConverse(function (_converse) {
it("can be unbookmarked", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {}, function (done, _converse) {
var sent_stanza, IQ_id;
var sendIQ = _converse.connection.sendIQ;
test_utils.openChatRoom(_converse, 'theplay', 'conference.shakespeare.lit', 'JC');
......@@ -216,6 +227,7 @@
"</pubsub>"+
"</iq>"
);
done();
}));
});
......@@ -293,8 +305,9 @@
*/
}));
it("can be retrieved from the XMPP server",
mock.initConverseWithConnectionSpies(['send'], function (_converse) {
it("can be retrieved from the XMPP server", mock.initConverseWithPromises(
['send'], ['rosterGroupsFetched'], {}, function (done, _converse) {
/* Client requests all items
* -------------------------
*
......@@ -366,11 +379,14 @@
expect(_converse.bookmarks.models.length).toBe(2);
expect(_converse.bookmarks.findWhere({'jid': 'theplay@conference.shakespeare.lit'}).get('autojoin')).toBe(true);
expect(_converse.bookmarks.findWhere({'jid': 'another@conference.shakespeare.lit'}).get('autojoin')).toBe(false);
done();
}));
describe("The rooms panel", function () {
it("shows a list of bookmarks", mock.initConverseWithConnectionSpies(['send'], function (_converse) {
it("shows a list of bookmarks", mock.initConverseWithPromises(
['send'], ['rosterGroupsFetched'], {}, function (done, _converse) {
var IQ_id;
expect(_.filter(_converse.connection.send.calls.all(), function (call) {
var stanza = call.args[0];
......@@ -415,10 +431,12 @@
}).c('nick').t('JC').up().up();
_converse.connection._dataRecv(test_utils.createRequest(stanza));
expect($('#chatrooms dl.bookmarks dd').length).toBe(3);
done();
}));
it("remembers the toggle state of the bookmarks list",
mock.initConverseWithConnectionSpies(['send'], function (_converse) {
it("remembers the toggle state of the bookmarks list", mock.initConverseWithPromises(
['send'], ['rosterGroupsFetched'], {}, function (done, _converse) {
var IQ_id;
expect(_.filter(_converse.connection.send.calls.all(), function (call) {
var stanza = call.args[0];
......@@ -462,15 +480,19 @@
$('#chatrooms .bookmarks-toggle').click();
expect($('#chatrooms dl.bookmarks dd:visible').length).toBe(1);
expect(_converse.bookmarksview.list_model.get('toggle-state')).toBe(_converse.OPENED);
done();
}));
});
});
describe("When hide_open_bookmarks is true and a bookmarked room is opened", function () {
it("can be closed", mock.initConverse({ hide_open_bookmarks: true }, function (_converse) {
test_utils.openControlBox().openRoomsPanel(_converse);
it("can be closed", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'],
{ hide_open_bookmarks: true },
function (done, _converse) {
test_utils.openControlBox().openRoomsPanel(_converse);
// XXX Create bookmarks view here, otherwise we need to mock stanza
// traffic for it to get created.
_converse.bookmarksview = new _converse.BookmarksView(
......@@ -502,6 +524,7 @@
view.close();
room_els = _converse.bookmarksview.el.querySelectorAll(".open-room");
expect(room_els.length).toBe(1);
done();
}));
});
}));
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -7,7 +7,6 @@
} (this, function (jasmine, converse, mock, test_utils) {
var b64_sha1 = converse.env.b64_sha1;
var _ = converse.env._;
var $ = converse.env.jQuery;
describe("Converse", function() {
......@@ -272,32 +271,38 @@
describe("The \"chats\" API", function() {
it("has a method 'get' which returns a wrapped chat box", mock.initConverse(function (_converse) {
test_utils.createContacts(_converse, 'current');
// Test on chat that doesn't exist.
expect(_converse.api.chats.get('non-existing@jabber.org')).toBeFalsy();
var jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
// Test on chat that's not open
var box = _converse.api.chats.get(jid);
expect(typeof box === 'undefined').toBeTruthy();
var chatboxview = _converse.chatboxviews.get(jid);
// Test for single JID
test_utils.openChatBoxFor(_converse, jid);
box = _converse.api.chats.get(jid);
expect(box instanceof Object).toBeTruthy();
expect(box.model.get('box_id')).toBe(b64_sha1(jid));
chatboxview = _converse.chatboxviews.get(jid);
expect(chatboxview.$el.is(':visible')).toBeTruthy();
// Test for multiple JIDs
var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
test_utils.openChatBoxFor(_converse, jid2);
var list = _converse.api.chats.get([jid, jid2]);
expect(_.isArray(list)).toBeTruthy();
expect(list[0].model.get('box_id')).toBe(b64_sha1(jid));
expect(list[1].model.get('box_id')).toBe(b64_sha1(jid2));
it("has a method 'get' which returns a wrapped chat box", mock.initConverseWithPromises(
null, ['rosterInitialized'], {}, function (done, _converse) {
test_utils.openControlBox();
test_utils.createContacts(_converse, 'current');
// Test on chat that doesn't exist.
expect(_converse.api.chats.get('non-existing@jabber.org')).toBeFalsy();
var jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
// Test on chat that's not open
var box = _converse.api.chats.get(jid);
expect(typeof box === 'undefined').toBeTruthy();
var chatboxview = _converse.chatboxviews.get(jid);
// Test for single JID
test_utils.openChatBoxFor(_converse, jid);
box = _converse.api.chats.get(jid);
expect(box instanceof Object).toBeTruthy();
expect(box.model.get('box_id')).toBe(b64_sha1(jid));
chatboxview = _converse.chatboxviews.get(jid);
expect(chatboxview.$el.is(':visible')).toBeTruthy();
// Test for multiple JIDs
var jid2 = mock.cur_names[1].replace(/ /g,'.').toLowerCase() + '@localhost';
test_utils.openChatBoxFor(_converse, jid2);
var list = _converse.api.chats.get([jid, jid2]);
expect(_.isArray(list)).toBeTruthy();
expect(list[0].model.get('box_id')).toBe(b64_sha1(jid));
expect(list[1].model.get('box_id')).toBe(b64_sha1(jid2));
done();
}));
it("has a method 'open' which opens and returns a wrapped chat box", mock.initConverse(function (_converse) {
it("has a method 'open' which opens and returns a wrapped chat box", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {}, function (done, _converse) {
test_utils.openControlBox();
test_utils.createContacts(_converse, 'current');
var jid = mock.cur_names[0].replace(/ /g,'.').toLowerCase() + '@localhost';
var chatboxview;
......@@ -318,6 +323,7 @@
expect(_.isArray(list)).toBeTruthy();
expect(list[0].model.get('box_id')).toBe(b64_sha1(jid));
expect(list[1].model.get('box_id')).toBe(b64_sha1(jid2));
done();
}));
});
......
......@@ -40,7 +40,9 @@
utils.isHeadlineMessage.restore();
}));
it("will open and display headline messages", mock.initConverse(function (_converse) {
it("will open and display headline messages", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {}, function (done, _converse) {
/* <message from='notify.example.com'
* to='romeo@im.example.com'
* type='headline'
......@@ -74,9 +76,12 @@
expect(utils.isHeadlineMessage.called).toBeTruthy();
expect(utils.isHeadlineMessage.returned(true)).toBeTruthy();
utils.isHeadlineMessage.restore(); // unwraps
done();
}));
it("will not show a headline messages from a full JID if allow_non_roster_messaging is false", mock.initConverse(function (_converse) {
it("will not show a headline messages from a full JID if allow_non_roster_messaging is false",
mock.initConverse(function (_converse) {
_converse.allow_non_roster_messaging = false;
sinon.spy(utils, 'isHeadlineMessage');
var stanza = $msg({
......
(function (root, factory) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
define(["jquery.noconflict", "jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function ($, jasmine, mock, converse, test_utils) {
"use strict";
var _ = converse.env._;
var $ = converse.env.jQuery;
var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq;
var $msg = converse.env.$msg;
......
......@@ -6,7 +6,11 @@
describe("The Minimized Chats Widget", function () {
it("shows chats that have been minimized", mock.initConverse(function (_converse) {
it("shows chats that have been minimized",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
......@@ -34,9 +38,14 @@
expect(_converse.minimized_chats.$el.is(':visible')).toBeTruthy();
expect(_converse.minimized_chats.keys().length).toBe(2);
expect(_.includes(_converse.minimized_chats.keys(), contact_jid)).toBeTruthy();
done();
}));
it("can be toggled to hide or show minimized chats", mock.initConverse(function (_converse) {
it("can be toggled to hide or show minimized chats",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
......@@ -56,9 +65,14 @@
_converse.minimized_chats.$('#toggle-minimized-chats').click();
expect(_converse.minimized_chats.$('.minimized-chats-flyout').is(':visible')).toBeFalsy();
expect(_converse.minimized_chats.toggleview.model.get('collapsed')).toBeTruthy();
done();
}));
it("shows the number messages received to minimized chats", mock.initConverse(function (_converse) {
it("shows the number messages received to minimized chats",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
......@@ -120,9 +134,14 @@
id: (new Date()).getTime()
}).c('inactive', {'xmlns': 'http://jabber.org/protocol/chatstates'}).tree());
expect(_converse.minimized_chats.toggleview.$('.unread-message-count').text()).toBe((i).toString());
done();
}));
it("shows the number messages received to minimized groupchats", mock.initConverse(function (_converse) {
it("shows the number messages received to minimized groupchats",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
var room_jid = 'kitchen@conference.shakespeare.lit';
test_utils.openAndEnterChatRoom(
_converse, 'kitchen', 'conference.shakespeare.lit', 'fires');
......@@ -142,6 +161,7 @@
expect(_converse.minimized_chats.toggleview.$('.unread-message-count').is(':visible')).toBeTruthy();
expect(_converse.minimized_chats.toggleview.$('.unread-message-count').text()).toBe('1');
done();
}));
});
}));
......@@ -12,7 +12,11 @@
describe("And the desktop is not focused", function () {
describe("an HTML5 Notification", function () {
it("is shown when a new private message is received", mock.initConverse(function (_converse) {
it("is shown when a new private message is received",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
// TODO: not yet testing show_desktop_notifications setting
test_utils.createContacts(_converse, 'current');
spyOn(_converse, 'showMessageNotification');
......@@ -30,9 +34,14 @@
_converse.chatboxes.onMessage(msg); // This will emit 'message'
expect(_converse.areDesktopNotificationsEnabled).toHaveBeenCalled();
expect(_converse.showMessageNotification).toHaveBeenCalled();
done();
}));
it("is shown when you are mentioned in a chat room", mock.initConverse(function (_converse) {
it("is shown when you are mentioned in a chat room",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy');
var view = _converse.chatboxviews.get('lounge@localhost');
......@@ -63,9 +72,14 @@
if (no_notification) {
delete window.Notification;
}
done();
}));
it("is shown for headline messages", mock.initConverse(function (_converse) {
it("is shown for headline messages",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
spyOn(_converse, 'showMessageNotification').and.callThrough();
spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true);
var stanza = $msg({
......@@ -84,6 +98,7 @@
'notify.example.com')
).toBeTruthy();
expect(_converse.showMessageNotification).toHaveBeenCalled();
done();
}));
it("is not shown for full JID headline messages if allow_non_roster_messaging is false", mock.initConverse(function (_converse) {
......@@ -137,7 +152,11 @@
describe("When play_sounds is set to true", function () {
describe("A notification sound", function () {
it("is played when the current user is mentioned in a chat room", mock.initConverse(function (_converse) {
it("is played when the current user is mentioned in a chat room",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.createContacts(_converse, 'current');
test_utils.openAndEnterChatRoom(_converse, 'lounge', 'localhost', 'dummy');
_converse.play_sounds = true;
......@@ -175,6 +194,7 @@
view.onChatRoomMessage(message.nodeTree);
expect(_converse.playSoundNotification, 1);
_converse.play_sounds = false;
done();
}));
});
});
......
(function (root, factory) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
var $ = converse.env.jQuery;
define(["jquery.noconflict", "jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function ($, jasmine, mock, converse, test_utils) {
var Strophe = converse.env.Strophe;
var b64_sha1 = converse.env.b64_sha1;
return describe("The OTR module", function() {
it("will add processing hints to sent out encrypted <message> stanzas", mock.initConverse(function (_converse) {
it("will add processing hints to sent out encrypted <message> stanzas",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
test_utils.createContacts(_converse, 'current');
......@@ -25,11 +28,16 @@
expect($hints.get(1).tagName).toBe('no-permanent-store');
expect($hints.get(2).tagName).toBe('no-copy');
chatview.model.set('otr_status', UNENCRYPTED); // Reset again to UNENCRYPTED
done();
}));
describe("An OTR Chat Message", function () {
it("will not be carbon copied when it's sent out", mock.initConverse(function (_converse) {
it("will not be carbon copied when it's sent out",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.openControlBox();
test_utils.openContactsPanel(_converse);
test_utils.createContacts(_converse, 'current');
......@@ -46,6 +54,7 @@
expect($sent.find('private').length).toBe(1);
expect($sent.find('private').attr('xmlns')).toBe('urn:xmpp:carbons:2');
chatbox.set('otr_status', 0); // Reset again to UNENCRYPTED
done();
}));
});
});
......
......@@ -6,20 +6,30 @@
describe("XMPP Ping", function () {
describe("Ping and pong handlers", function () {
it("are registered when _converse.js is connected", mock.initConverse(function (_converse) {
it("are registered when _converse.js is connected",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
spyOn(_converse, 'registerPingHandler').and.callThrough();
spyOn(_converse, 'registerPongHandler').and.callThrough();
_converse.emit('connected');
expect(_converse.registerPingHandler).toHaveBeenCalled();
expect(_converse.registerPongHandler).toHaveBeenCalled();
done();
}));
it("are registered when _converse.js reconnected", mock.initConverse(function (_converse) {
it("are registered when _converse.js reconnected",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
spyOn(_converse, 'registerPingHandler').and.callThrough();
spyOn(_converse, 'registerPongHandler').and.callThrough();
_converse.emit('reconnected');
expect(_converse.registerPingHandler).toHaveBeenCalled();
expect(_converse.registerPongHandler).toHaveBeenCalled();
done();
}));
});
......
......@@ -49,7 +49,11 @@
describe("A received presence stanza", function () {
it("has its priority taken into account", mock.initConverse(function (_converse) {
it("has its priority taken into account",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.openControlBox();
test_utils.createContacts(_converse, 'current'); // Create some contacts so that we can test positioning
var contact_jid = mock.cur_names[8].replace(/ /g,'.').toLowerCase() + '@localhost';
......@@ -218,6 +222,7 @@
_converse.connection._dataRecv(test_utils.createRequest(stanza[0]));
expect(_converse.roster.get(contact_jid).get('chat_status')).toBe('offline');
expect(_.keys(contact.get('resources')).length).toBe(0);
done();
}));
});
}));
......
......@@ -10,6 +10,7 @@
var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq;
var $pres = converse.env.$pres;
var _ = converse.env._;
// See:
// https://xmpp.org/rfcs/rfc3921.html
......@@ -47,11 +48,15 @@
* that session. A client MUST acknowledge each roster push with an IQ
* stanza of type "result".
*/
it("Subscribe to contact, contact accepts and subscribes back", mock.initConverseWithAsync(function (done, _converse) {
it("Subscribe to contact, contact accepts and subscribes back",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'],
{ roster_groups: false },
function (done, _converse) {
/* The process by which a user subscribes to a contact, including
* the interaction between roster items and subscription states.
*/
_converse.roster_groups = false;
var contact, stanza, sent_stanza, IQ_id;
test_utils.openControlBox(_converse);
var panel = _converse.chatboxviews.get('controlbox').contactspanel;
......@@ -134,8 +139,10 @@
* </iq>
*/
var create = _converse.roster.create;
var sent_stanzas = [];
spyOn(_converse.connection, 'send').and.callFake(function (stanza) {
sent_stanza = stanza;
sent_stanzas.push(stanza.toLocaleString());
});
spyOn(_converse.roster, 'create').and.callFake(function () {
contact = create.apply(_converse.roster, arguments);
......@@ -165,6 +172,11 @@
*
* <presence to='contact@example.org' type='subscribe'/>
*/
test_utils.waitUntil(function () {
return sent_stanzas.length == 1;
}).then(function () {
expect(contact.subscribe).toHaveBeenCalled();
expect(sent_stanza.toLocaleString()).toBe( // Strophe adds the xmlns attr (although not in spec)
"<presence to='contact@example.org' type='subscribe' xmlns='jabber:client'>"+
......@@ -347,9 +359,14 @@
expect($contacts.hasClass('both')).toBeTruthy();
done();
});
});
}));
it("Alternate Flow: Contact Declines Subscription Request", mock.initConverse(function (_converse) {
it("Alternate Flow: Contact Declines Subscription Request",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
/* The process by which a user subscribes to a contact, including
* the interaction between roster items and subscription states.
*/
......@@ -429,11 +446,16 @@
"</query>"+
"</iq>"
);
done();
}));
it("Unsubscribe to a contact when subscription is mutual", mock.initConverseWithAsync(function (done, _converse) {
it("Unsubscribe to a contact when subscription is mutual",
mock.initConverseWithPromises(
null, ['rosterGroupsFetched'],
{ roster_groups: false },
function (done, _converse) {
var sent_IQ, IQ_id, jid = 'annegreet.gomez@localhost';
_converse.roster_groups = false;
test_utils.openControlBox(_converse);
test_utils.createContacts(_converse, 'current');
spyOn(window, 'confirm').and.returnValue(true);
......@@ -490,7 +512,10 @@
});
}));
it("Receiving a subscription request", mock.initConverse(function (_converse) {
it("Receiving a subscription request", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'], {},
function (done, _converse) {
test_utils.openControlBox(_converse);
test_utils.createContacts(_converse, 'current'); // Create some contacts so that we can test positioning
spyOn(_converse, "emit");
......@@ -516,6 +541,7 @@
expect($header.is(":visible")).toBeTruthy();
var $contacts = $header.parent().nextUntil('dt', 'dd');
expect($contacts.length).toBe(1);
done();
});
}));
});
......
(function (root, factory) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
var $ = converse.env.jQuery;
define(["jquery.noconflict", "jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function ($, jasmine, mock, converse, test_utils) {
var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq;
......
......@@ -7,12 +7,13 @@
describe("The converse-roomslist plugin", function () {
it("is shown under a list of open rooms in the \"Rooms\" panel", mock.initConverse(
it("is shown under a list of open rooms in the \"Rooms\" panel", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'],
{ whitelisted_plugins: ['converse-roomslist'],
allow_bookmarks: false // Makes testing easier, otherwise we
// have to mock stanza traffic.
},
function (_converse) {
function (done, _converse) {
test_utils.openControlBox().openRoomsPanel(_converse);
var controlbox = _converse.chatboxviews.get('controlbox');
......@@ -46,18 +47,20 @@
list = controlbox.el.querySelector('div.rooms-list-container');
expect(_.includes(list.classList, 'hidden')).toBeTruthy();
done();
}
));
});
describe("An room shown in the rooms list", function () {
it("can be closed", mock.initConverse(
it("can be closed", mock.initConverseWithPromises(
null, ['rosterGroupsFetched'],
{ whitelisted_plugins: ['converse-roomslist'],
allow_bookmarks: false // Makes testing easier, otherwise we
// have to mock stanza traffic.
},
function (_converse) {
function (done, _converse) {
spyOn(window, 'confirm').and.callFake(function () {
return true;
......@@ -76,6 +79,7 @@
room_els = _converse.rooms_list_view.el.querySelectorAll(".open-room");
expect(room_els.length).toBe(0);
expect(_converse.chatboxes.length).toBe(1);
done();
}));
it("shows unread messages directed at the user", mock.initConverseWithAsync(
......
(function (root, factory) {
define([
"jquery.noconflict",
"converse-core",
"mock",
"test_utils",
......@@ -7,10 +8,9 @@
"transcripts"
], factory
);
} (this, function (converse, mock, test_utils, utils, transcripts) {
} (this, function ($, converse, mock, test_utils, utils, transcripts) {
var Strophe = converse.env.Strophe;
var _ = converse.env._;
var $ = converse.env.jQuery;
var IGNORED_TAGS = [
'stream:features',
'auth',
......
(function (root, factory) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
var $ = converse.env.jQuery;
define(["jquery.noconflict", "jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function ($, jasmine, mock, converse, test_utils) {
return describe("The XMPPStatus model", function() {
......
......@@ -2,6 +2,7 @@
define("mock", ['jquery.noconflict', 'converse'], factory);
}(this, function ($, converse_api) {
var _ = converse_api.env._;
var Promise = converse_api.env.Promise;
var Strophe = converse_api.env.Strophe;
var $iq = converse_api.env.$iq;
var mock = {};
......@@ -76,7 +77,7 @@
};
}();
function initConverse (settings, spies) {
function initConverse (settings, spies, promises) {
window.localStorage.clear();
window.sessionStorage.clear();
......@@ -105,6 +106,14 @@
return converse;
}
mock.initConverseWithPromises = function (spies, promise_names, settings, func) {
return function (done) {
var _converse = initConverse(settings, spies);
var promises = _.map(promise_names, _converse.api.waitUntil);
Promise.all(promises).then(_.partial(func, done, _converse));
}
};
mock.initConverseWithConnectionSpies = function (spies, settings, func) {
if (_.isFunction(settings)) {
var _func = settings;
......
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