Skip to content

Commit

Permalink
wip remove uses of callback api in test, missed in 43a2d1d
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrence-forooghian committed Dec 12, 2023
1 parent 8700889 commit 6c0a302
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 35 deletions.
8 changes: 4 additions & 4 deletions test/realtime/channel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1100,13 +1100,13 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async

realtime.connection.on('connected', function () {
channelByEvent = realtime.channels.get('channelsubscribe1-event');
channelByEvent.subscribe('event', listenerByEvent, function () {
whenPromiseSettles(channelByEvent.subscribe('event', listenerByEvent), function () {
channelByEvent.publish('event', 'data');
channelByListener = realtime.channels.get('channelsubscribe1-listener');
channelByListener.subscribe(null, listenerNoEvent, function () {
whenPromiseSettles(channelByListener.subscribe(null, listenerNoEvent), function () {
channelByListener.publish(null, 'data');
channelAll = realtime.channels.get('channelsubscribe1-all');
channelAll.subscribe(listenerAllEvents, function () {
whenPromiseSettles(channelAll.subscribe(listenerAllEvents), function () {
channelAll.publish(null, 'data');
});
});
Expand Down
9 changes: 4 additions & 5 deletions test/realtime/crypto.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -594,17 +594,16 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
return;
}
var rxChannel = rxRealtime.channels.get(channelName, { cipher: { key: key } });
rxChannel.subscribe(
'event0',
function (msg) {
whenPromiseSettles(
rxChannel.subscribe('event0', function (msg) {
try {
expect(msg.data == messageText).to.be.ok;
} catch (err) {
closeAndFinish(done, [txRealtime, rxRealtime], err);
return;
}
closeAndFinish(done, [txRealtime, rxRealtime]);
},
}),
function () {
var txChannel = txRealtime.channels.get(channelName, { cipher: { key: key } });
txChannel.publish('event0', messageText);
Expand Down
6 changes: 3 additions & 3 deletions test/realtime/failure.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
});
},
function (callback) {
failChan.subscribe('event', noop, function (err) {
whenPromiseSettles(failChan.subscribe('event', noop), function (err) {
try {
expect(err, 'subscribe failed').to.be.ok;
expect(err.code).to.equal(channelFailedCode, 'subscribe failure code');
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand Down
10 changes: 4 additions & 6 deletions test/realtime/message.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
async.eachSeries(
testArguments,
function iterator(args, callback) {
args.push(callback);
restChannel.publish.apply(restChannel, args);
whenPromiseSettles(restChannel.publish.apply(restChannel, args), callback);
},
function (err) {
if (err) {
Expand Down Expand Up @@ -607,12 +606,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();
Expand Down
6 changes: 3 additions & 3 deletions test/realtime/presence.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,16 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
var channelName = 'presenceMessageAction';
var clientChannel = clientRealtime.channels.get(channelName);
var presence = clientChannel.presence;
presence.subscribe(
function (presenceMessage) {
whenPromiseSettles(
presence.subscribe(function (presenceMessage) {
try {
expect(presenceMessage.action).to.equal('enter', 'Action should contain string "enter"');
} catch (err) {
closeAndFinish(done, clientRealtime, err);
return;
}
closeAndFinish(done, clientRealtime);
},
}),
function onPresenceSubscribe(err) {
if (err) {
closeAndFinish(done, clientRealtime, err);
Expand Down
10 changes: 5 additions & 5 deletions test/realtime/shared/delta_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});

Expand Down Expand Up @@ -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);
});
});

Expand Down
16 changes: 7 additions & 9 deletions test/realtime/upgrade.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define(['shared_helper', 'async', 'chai', 'ably'], function (helper, async, chai
var rest;
var publishIntervalHelper = function (currentMessageNum, channel, dataFn, onPublish) {
return function (currentMessageNum) {
channel.publish('event0', dataFn(), function () {
whenPromiseSettles(channel.publish('event0', dataFn()), function () {
onPublish();
});
};
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 6c0a302

Please sign in to comment.