diff --git a/static/test.js b/static/test.js index c7bc8dd..8bbbeff 100644 --- a/static/test.js +++ b/static/test.js @@ -274,6 +274,26 @@ test('getMessages/subscribe', function() { cosmo.shutdown(); }); +asyncTest('subscribe barrier', function() { + expect(2); + + var subject = randstring(); + var message = randstring(); + + var cosmo = new Cosmopolite({}, null, randstring()); + + cosmo.sendMessage(subject, message).then(function() { + cosmo.subscribe(subject, -1).then(function() { + // We are validating that the message event generated by the subscribe + // call has already been processed by the time this promise fires + equal(cosmo.getMessages(subject).length, 1, 'one message'); + equal(cosmo.getMessages(subject)[0]['message'], message, 'message matches'); + cosmo.shutdown(); + start(); + }); + }); +}); + module('dev_appserver only');