(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); // The timeout is used to slow down the tests so that one can see // visually what is happening in the page. this.timeout = 1000; 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)); // by default the dts are hidden from css class and only later they will be hidden // by jQuery therefore for the first check we will see if visible instead of none it("hides the requesting contacts heading if there aren't any", $.proxy(function () { expect(this.rosterview.$el.find('dt#xmpp-contact-requests').is(':visible')).toEqual(false); }, xmppchat)); it("can add requesting contacts, and they should be sorted alphabetically", $.proxy(function () { var i, t; spyOn(this.rosterview, 'render').andCallThrough(); spyOn(this, 'showControlBox').andCallThrough(); for (i=0; i