From 050b95b370478c7e0aab96472efc0363a35a9a44 Mon Sep 17 00:00:00 2001 From: Lawrence Forooghian Date: Tue, 20 Jun 2023 17:46:09 -0300 Subject: [PATCH] Prepare realtime channel publish disallowed test for conversion to Promise API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- test/realtime/message.test.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/test/realtime/message.test.js b/test/realtime/message.test.js index 03143bac53..3cd4f663e5 100644 --- a/test/realtime/message.test.js +++ b/test/realtime/message.test.js @@ -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);