Make subscribe/unsubscribe/sendMessage return Promises that fire on RPC return.

This commit is contained in:
Ian Gulliver
2014-05-17 16:52:28 +03:00
parent 96b17ad6ff
commit 994afde51f
2 changed files with 81 additions and 29 deletions

View File

@@ -174,6 +174,47 @@ asyncTest('Complex object', function() {
var cosmo = new Cosmopolite(callbacks, null, randstring());
});
asyncTest('sendMessage Promise', function() {
expect(1);
var subject = randstring();
var message = randstring();
var callbacks = {
'onReady': function() {
cosmo.sendMessage(subject, message).then(function() {
ok(true, 'sendMessage Promise fulfilled');
cosmo.shutdown();
start();
});
},
};
var cosmo = new Cosmopolite(callbacks, null, randstring());
});
asyncTest('subscribe/unsubscribe Promise', function() {
expect(2);
var subject = randstring();
var message = randstring();
var callbacks = {
'onReady': function() {
cosmo.subscribe(subject).then(function() {
ok(true, 'subscribe Promise fulfilled');
cosmo.unsubscribe(subject).then(function() {
ok(true, 'unsubscribe Promise fulfilled');
cosmo.shutdown();
start();
});
});
},
};
var cosmo = new Cosmopolite(callbacks, null, randstring());
});
module('dev_appserver only');