From 6088417df70cdfd431310d38816d23df728ce0d8 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 24 Oct 2014 22:24:05 +0200 Subject: [PATCH] Add an outline to the profiling tests. --- spec/profiling.js | 50 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/spec/profiling.js b/spec/profiling.js index 0421f37c9..78c167e3b 100644 --- a/spec/profiling.js +++ b/spec/profiling.js @@ -15,42 +15,40 @@ converse.connection._changeConnectStatus(Strophe.Status.CONNECTED); }); - xit("adds contacts on presence stanza", $.proxy(function() { + it("adds hundreds of contacts to the roster", $.proxy(function() { + }, converse)); + + it("adds hundreds of contacts to the roster, with roster groups", $.proxy(function() { + // XXX: Try with groups for now (might also add a test without groups) + converse.roster_groups = true; + spyOn(this.roster, 'clearCache').andCallThrough(); expect(this.roster.pluck('jid').length).toBe(0); - var stanza = $pres({from: 'data@enterprise/resource', type: 'subscribe'}); - this.connection._dataRecv(test_utils.createRequest(stanza)); - expect(this.roster.pluck('jid').length).toBe(1); - expect(_.contains(this.roster.pluck('jid'), 'data@enterprise')).toBeTruthy(); - - // Taken from the spec - // http://xmpp.org/rfcs/rfc3921.html#rfc.section.7.3 - stanza = $iq({ + var stanza = $iq({ to: this.connection.jid, type: 'result', id: 'roster_1' }).c('query', { - xmlns: 'jabber:iq:roster', - }).c('item', { - jid: 'romeo@example.net', - name: 'Romeo', - subscription:'both' - }).c('group').t('Friends').up().up() - .c('item', { - jid: 'mercutio@example.org', - name: 'Mercutio', - subscription:'from' - }).c('group').t('Friends').up().up() - .c('item', { - jid: 'benvolio@example.org', - name: 'Benvolio', - subscription:'both' - }).c('group').t('Friends'); + xmlns: 'jabber:iq:roster' + }); + + _.each(['Friends', 'Colleagues', 'Family', 'Acquaintances'], function (group) { + var i, prefix = group.toLowerCase(); + for (i=0; i<100; i++) { + stanza = stanza.c('item', { + jid: prefix+i+'@example.net', + subscription:'both' + }).c('group').t('Friends').up().up(); + } + }); this.connection.roster._onReceiveRosterSuccess(null, stanza.tree()); expect(this.roster.clearCache).toHaveBeenCalled(); - expect(_.contains(this.roster.pluck('jid'), 'data@enterprise')).toBeTruthy(); + expect(this.roster.pluck('jid').length).toBe(400); + }, converse)); + + it("contacts in a very large roster change their statuses", $.proxy(function() { }, converse)); });