(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', 'Dirk Eichel', 'Marco Duerr', 'Ute Schiffer', 'Billie Westerhuis', 'Sarah Kuester', 'Sabrina Loewe', 'Laura Duerr', 'Mathias Meyer', 'Tijm Keller', 'Lea Gerste', 'Martin Pfeffer', 'Ulrike Abt', 'Zoubida van Rooij', 'Maylin Hettema', 'Ruwan Bechan', 'Marco Beich', 'Karin Busch', 'Mathias Müller' ]; var pend_names = [ 'Suleyman van Beusichem', 'Nicole Diederich', 'Nanja van Yperen', 'Delany Bloemendaal', 'Jannah Hofmeester', 'Christine Trommler', 'Martin Bumgarner', 'Emil Baeten', 'Farshad Brasser', 'Gabriele Fisher', 'Sofiane Schopman', 'Sky Wismans', 'Jeffery Stoelwinder', 'Ganesh Waaijenberg', 'Dani Boldewijn', 'Katrin Propst', 'Martina Kaiser', 'Philipp Kappel', 'Meeke Grootendorst' ]; 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', 'Ben Zomer', 'Leah Weiss', 'Francesca Disseldorp', 'Sven Bumgarner', 'Benjamin Zweig' ]; 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': { 'registerCallback': function () {}, 'get': function () {} } }; // 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)); this.prebind = true; this.onConnected(mock_connection); this.animate = false; // don't use animations // The timeout is used to slow down the tests so that one can see // visually what is happening in the page. var timeout = 0; var sleep = function (delay) { // Yes this is blocking and stupid, but these are tests and this is // the easiest way to delay execution without having to use // callbacks. var start = new Date().getTime(); while (new Date().getTime() < start + delay) { continue; } }; 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)); it("hides the pending contacts heading if there aren't any", $.proxy(function () { expect(this.rosterview.$el.find('dt#pending-xmpp-contacts').css('display')).toEqual('none'); }, xmppchat)); it("can add pending contacts, and they should be sorted alphabetically", $.proxy(function () { var i, t, is_last; spyOn(this.rosterview, 'render').andCallThrough(); for (i=0; i