From c8c968a2aaf79ab812b34e58f654e86da0fd0378 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 18 May 2014 18:49:34 +0300 Subject: [PATCH] Add test for getMessages/subscribe interaction. Move other tests into their own namespaces. --- static/test.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/static/test.js b/static/test.js index c225423..59cf186 100644 --- a/static/test.js +++ b/static/test.js @@ -65,7 +65,7 @@ module('All platforms'); test('Construct/shutdown', function() { expect(2); - var cosmo = new Cosmopolite({}); + var cosmo = new Cosmopolite({}, null, randstring()); ok(true, 'new Cosmopolite() succeeds'); cosmo.shutdown(); ok(true, 'shutdown() succeeds'); @@ -82,7 +82,7 @@ asyncTest('onLogout fires', function() { start(); } }; - var cosmo = new Cosmopolite(callbacks); + var cosmo = new Cosmopolite(callbacks, null, randstring()); }); }); @@ -257,6 +257,23 @@ asyncTest('Message persistence', function() { // Should pick up the message from the persistent queue. }); +test('getMessages/subscribe', function() { + expect(2); + + var subject = randstring(); + + var cosmo = new Cosmopolite({}, null, randstring()); + throws( + cosmo.getMessages.bind(undefined, subject), + 'getMessages before subscribe fails'); + cosmo.subscribe(subject); + // Verify that we can call getMessages immediately after subscribe + cosmo.getMessages(subject); + ok(true, 'getMessages after subscribe succeeds'); + + cosmo.shutdown(); +}); + module('dev_appserver only'); @@ -281,7 +298,7 @@ asyncTest('Login', function() { start(); }, }; - var cosmo = new Cosmopolite(callbacks); + var cosmo = new Cosmopolite(callbacks, null, randstring()); }); }); @@ -317,7 +334,7 @@ asyncTest('Profile merge', function() { cosmo.subscribe(subject, -1); }, }; - var cosmo = new Cosmopolite(callbacks); + var cosmo = new Cosmopolite(callbacks, null, randstring()); cosmo.sendMessage(subject, message); cosmo.subscribe(subject, -1); });