Skip to content

Commit

Permalink
Prepare realtime channel publish disallowed test for conversion to Pr…
Browse files Browse the repository at this point in the history
…omise API

When we switch to using the Promise-based API, we’ll need to wait for
the result of `publish`, so let’s put the supporting code in place for
that.
  • Loading branch information
lawrence-forooghian committed Jun 27, 2023
1 parent a1c3592 commit 050b95b
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions test/realtime/message.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,22 +440,25 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async
return;
}

/* publish events */
var restChannel = rest.channels.get('publishDisallowed');
for (var i = 0; i < testArguments.length; i++) {
try {
restChannel.publish.apply(restChannel, testArguments[i]);
closeAndFinish(done, realtime, new Error('Exception was not raised'));
} catch (err) {
(async function () {
/* publish events */
var restChannel = rest.channels.get('publishDisallowed');
for (var i = 0; i < testArguments.length; i++) {
try {
expect(err.code).to.equal(40013, 'Invalid data type exception raised');
restChannel.publish.apply(restChannel, testArguments[i]);
closeAndFinish(done, realtime, new Error('Exception was not raised'));
} catch (err) {
closeAndFinish(done, realtime, err);
return;
try {
expect(err.code).to.equal(40013, 'Invalid data type exception raised');
} catch (err) {
closeAndFinish(done, realtime, err);
return;
}
}
}
}
closeAndFinish(done, realtime);
})().then(() => {
closeAndFinish(done, realtime);
});
});
});
monitorConnection(done, realtime);
Expand Down

0 comments on commit 050b95b

Please sign in to comment.