(function (root, factory) { define([ "converse" ], function (xmppchat) { return factory(xmppchat); } ); } (this, function (xmppchat) { return describe("Converse.js", $.proxy(function() { // Names from http://www.fakenamegenerator.com/ var req_names = [ 'Louw Spekman', 'Mohamad Stet', 'Dominik Beyer' ]; var pend_names = [ 'Suleyman van Beusichem', 'Nicole Diederich', 'Nanja van Yperen' ]; var cur_names = [ 'Max Frankfurter', 'Candice van der Knijff', 'Irini Vlastuin', 'Rinse Sommer', 'Annegreet Gomez', 'Robin Schook', 'Marcel Eberhardt', 'Simone Brauer', 'Asmaa Haakman', 'Felix Amsel', 'Lena Grunewald', 'Laura Grunewald', 'Mandy Seiler', 'Sven Bosch', 'Nuriye Cuypers' ]; var num_contacts = req_names.length + pend_names.length + cur_names.length; this.bare_jid = 'dummy@localhost'; mock_connection = { 'muc': { 'listRooms': function () {} }, 'jid': this.bare_jid, 'addHandler': function (handler, ns, name, type, id, from, options) { return function () {}; }, 'roster': { 'add': function () {}, 'authorize': function () {}, 'unauthorize': function () {}, 'get': function () {}, 'subscribe': function () {}, 'registerCallback': function () {} }, 'vcard': { 'get': function (callback, jid) { var name = jid.split('@')[0].replace('.', ' ').split(' '); var firstname = name[0].charAt(0).toUpperCase()+name[0].slice(1); var lastname = name[1].charAt(0).toUpperCase()+name[1].slice(1); var fullname = firstname+' '+lastname; var vcard = $iq().c('vCard').c('FN').t(fullname); callback(vcard.tree()); } } }; // Clear localStorage window.localStorage.removeItem( hex_sha1('converse.rosteritems-'+this.bare_jid)); window.localStorage.removeItem( hex_sha1('converse.chatboxes-'+this.bare_jid)); window.localStorage.removeItem( hex_sha1('converse.xmppstatus-'+this.bare_jid)); window.localStorage.removeItem( hex_sha1('converse.messages'+cur_names[0].replace(' ','.').toLowerCase() + '@localhost')); this.prebind = true; this.onConnected(mock_connection); this.animate = false; // don't use animations describe("The Contacts Roster", $.proxy(function () { it("is not shown by default", $.proxy(function () { expect(this.rosterview.$el.is(':visible')).toEqual(false); }, xmppchat)); it("can be opened by clicking a DOM element with id 'toggle-online-users'", $.proxy(function () { spyOn(this, 'toggleControlBox').andCallThrough(); $('#toggle-online-users').click(); expect(this.toggleControlBox).toHaveBeenCalled(); }, xmppchat)); describe("Pending Contacts", $.proxy(function () { it("do not have a heading if there aren't any", $.proxy(function () { expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').css('display')).toEqual('none'); }, xmppchat)); it("can be added to the roster and they will be sorted alphabetically", $.proxy(function () { var i, t, is_last; spyOn(this.rosterview, 'render').andCallThrough(); for (i=0; i