diff --git a/test/realtime/channel.test.js b/test/realtime/channel.test.js index ac745fb036..6968c4ad06 100644 --- a/test/realtime/channel.test.js +++ b/test/realtime/channel.test.js @@ -686,7 +686,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async async.series( [ function (cb) { - channel.attach(cb); + whenPromiseSettles(channel.attach(), cb); }, function (cb) { var channelUpdated = false; diff --git a/test/realtime/crypto.test.js b/test/realtime/crypto.test.js index 407dbc6e25..d64f4544c2 100644 --- a/test/realtime/crypto.test.js +++ b/test/realtime/crypto.test.js @@ -473,7 +473,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async }); } - channel.attach(function (err) { + whenPromiseSettles(channel.attach(), function (err) { if (err) { closeAndFinish(done, realtime, err); return; diff --git a/test/realtime/failure.test.js b/test/realtime/failure.test.js index 23c05a7e3a..52979fc228 100644 --- a/test/realtime/failure.test.js +++ b/test/realtime/failure.test.js @@ -284,7 +284,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async }); }, function (callback) { - failChan.presence.subscribe('event', noop, function (err) { + whenPromiseSettles(failChan.presence.subscribe('event', noop), function (err) { try { expect(err, 'presence subscribe failed').to.be.ok; expect(err.code).to.equal(channelFailedCode, 'subscribe failure code'); @@ -295,7 +295,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async }); }, function (callback) { - failChan.presence.subscribe('event', noop, function (err) { + whenPromiseSettles(failChan.presence.subscribe('event', noop), function (err) { try { expect(err, 'presence unsubscribe failed').to.be.ok; expect(err.code).to.equal(channelFailedCode, 'subscribe failure code'); diff --git a/test/realtime/message.test.js b/test/realtime/message.test.js index 11f5ff37e4..63ad7ca234 100644 --- a/test/realtime/message.test.js +++ b/test/realtime/message.test.js @@ -607,12 +607,11 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async var realtime = helper.AblyRealtime(realtimeOpts); var channel = realtime.channels.get('publish ' + JSON.stringify(realtimeOpts)); /* subscribe to event */ - channel.subscribe( - 'event0', - function () { + whenPromiseSettles( + channel.subscribe('event0', function () { --count; checkFinish(); - }, + }), function () { var dataFn = function () { return 'Hello world at: ' + new Date(); diff --git a/test/realtime/shared/delta_tests.js b/test/realtime/shared/delta_tests.js index 0de7ebde1f..a70bb9b685 100644 --- a/test/realtime/shared/delta_tests.js +++ b/test/realtime/shared/delta_tests.js @@ -91,7 +91,7 @@ define(['shared_helper', 'async', 'chai'], function (helper, async, chai) { }); async.timesSeries(testData.length, function (i, cb) { - channel.publish(i.toString(), testData[i], cb); + whenPromiseSettles(channel.publish(i.toString(), testData[i]), cb); }); }); @@ -129,7 +129,7 @@ define(['shared_helper', 'async', 'chai'], function (helper, async, chai) { }); async.timesSeries(testData.length, function (i, cb) { - channel.publish(i.toString(), testData[i], cb); + whenPromiseSettles(channel.publish(i.toString(), testData[i]), cb); }); }); @@ -193,7 +193,7 @@ define(['shared_helper', 'async', 'chai'], function (helper, async, chai) { }); async.timesSeries(testData.length, function (i, cb) { - channel.publish(i.toString(), testData[i], cb); + whenPromiseSettles(channel.publish(i.toString(), testData[i]), cb); }); }); @@ -241,7 +241,7 @@ define(['shared_helper', 'async', 'chai'], function (helper, async, chai) { }); async.timesSeries(testData.length, function (i, cb) { - channel.publish(i.toString(), testData[i], cb); + whenPromiseSettles(channel.publish(i.toString(), testData[i]), cb); }); }); @@ -273,7 +273,7 @@ define(['shared_helper', 'async', 'chai'], function (helper, async, chai) { closeAndFinish(done, realtime); }); async.timesSeries(testData.length, function (i, cb) { - channel.publish(i.toString(), testData[i], cb); + whenPromiseSettles(channel.publish(i.toString(), testData[i]), cb); }); }); diff --git a/test/realtime/upgrade.test.js b/test/realtime/upgrade.test.js index 3ae14f839c..b82e8ec46a 100644 --- a/test/realtime/upgrade.test.js +++ b/test/realtime/upgrade.test.js @@ -223,12 +223,11 @@ define(['shared_helper', 'async', 'chai', 'ably'], function (helper, async, chai var realtime = helper.AblyRealtime(transportOpts); var channel = realtime.channels.get('upgradepublish0'); /* subscribe to event */ - channel.subscribe( - 'event0', - function () { + whenPromiseSettles( + channel.subscribe('event0', function () { --count; checkFinish(); - }, + }), function () { var dataFn = function () { return 'Hello world at: ' + new Date(); @@ -257,12 +256,11 @@ define(['shared_helper', 'async', 'chai', 'ably'], function (helper, async, chai var realtime = helper.AblyRealtime(transportOpts); var channel = realtime.channels.get('upgradepublish1'); /* subscribe to event */ - channel.subscribe( - 'event0', - function () { + whenPromiseSettles( + channel.subscribe('event0', function () { --count; checkFinish(); - }, + }), function () { var dataFn = function () { return 'Hello world at: ' + new Date();