Skip to content

Commit

Permalink
test: ensure realtime clients are disposed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
owenpearson committed Feb 29, 2024
1 parent f5eda71 commit 7bb17d1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
19 changes: 12 additions & 7 deletions test/realtime/channel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1479,11 +1479,16 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async

channel.state = 'suspended';
whenPromiseSettles(channel.detach(), function () {
expect(channel.state).to.equal(
'detached',
'Check that detach on suspended channel results in detached channel'
);
done();
try {
expect(channel.state).to.equal(
'detached',
'Check that detach on suspended channel results in detached channel'
);

closeAndFinish(done, realtime);
} catch (err) {
closeAndFinish(done, realtime, err);
}
});
});

Expand All @@ -1497,10 +1502,10 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async

whenPromiseSettles(channel.detach(), function (err) {
if (!err) {
done(new Error('expected detach to return error response'));
closeAndFinish(done, realtime, new Error('expected detach to return error response'));
return;
}
done();
closeAndFinish(done, realtime);
});
});

Expand Down
20 changes: 9 additions & 11 deletions test/realtime/connectivity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,20 @@ define(['ably', 'shared_helper', 'chai'], function (Ably, helper, chai) {
});
});

function options(connectivityCheckUrl, disableConnectivityCheck) {
return {
connectivityCheckUrl,
disableConnectivityCheck,
autoConnect: false,
};
}

describe('configured_connectivity_check_url', function () {
var urlScheme = 'https://';
var echoServer = 'echo.ably.io';
var successUrl = echoServer + '/respondwith?status=200';
var failUrl = echoServer + '/respondwith?status=500';

function options(connectivityCheckUrl) {
return {
connectivityCheckUrl: connectivityCheckUrl,
autoConnect: false,
};
}

it('succeeds with scheme', function (done) {
whenPromiseSettles(
new helper.AblyRealtime(options(urlScheme + successUrl)).http.checkConnectivity(),
Expand Down Expand Up @@ -129,10 +130,7 @@ define(['ably', 'shared_helper', 'chai'], function (Ably, helper, chai) {

it('disable_connectivity_check', function (done) {
whenPromiseSettles(
new helper.AblyRealtime({
connectivityCheckUrl: 'notarealhost',
disableConnectivityCheck: true,
}).http.checkConnectivity(),
new helper.AblyRealtime(options('notarealhost', true)).http.checkConnectivity(),
function (err, res) {
try {
expect(res && !err, 'Connectivity check completed ' + (err && utils.inspectError(err))).to.be.ok;
Expand Down

0 comments on commit 7bb17d1

Please sign in to comment.