Skip to content

Commit 20f050b

Browse files
committed
Fix integration.test.ts used deprecated callback for RealtimeChannel.whenState()
Callback API for RealtimeChannel.whenState() was removed in ably-js v2 [1] [1] ably/ably-js@2a2ed49
1 parent ba0e2bb commit 20f050b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

test/integration/integration.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ describe(
187187
it('scenario 2.2: set cursor position', async () => {
188188
// Before calling `performerSpace.cursors.set()` below, we want to be sure that `performerSpace.cursors` has found out about the presence enter operations triggered by calling `performerSpace.cursors.set()` in scenario 2.1, and by calling `observerSpace.cursors.subscribe()` below, so that it doesn’t drop the cursor updates that we pass to `set()`. So here we set up a promise which will resolve once `performerSpace.cursors.channel` sees two clients (i.e. `performerSpaces` and `observerSpaces`) as present.
189189
const performerCursorsChannelObserverPresentPromise = new Promise<void>((resolve) => {
190-
const presence = performerSpace.cursors.channel.presence;
190+
const presence = performerSpace.cursors.channel!.presence;
191191
const listener = async () => {
192192
const members = await presence.get();
193193
if (members.length === 2) {
@@ -215,9 +215,7 @@ describe(
215215
// To be sure that the `observerSpace.cursors.subscribe()` listener will receive the cursor positions sent by the calls to `performerSpace.cursors.set()` below, we need to know that the cursors channel attach operation triggered by calling `observerSpace.cursors.subscribe()` has completed. The `cursors.subscribe()` API does not currently provide any direct way for the user to know that this attach operation has completed, so here we do so by directly observing the channel.
216216
//
217217
// We should consider exposing the completion of the attach operation via the `cursors.subscribe()` API, the same way as ably-js exposes it through `presence.subscribe()`. I’m not convinced of the necessity though — not sure how useful it’d be for an average user, and we can work around it in tests (as I have here).
218-
const observerCursorsChannelAttachedPromise = new Promise((resolve) => {
219-
observerSpace.cursors.channel.whenState('attached', resolve);
220-
});
218+
const observerCursorsChannelAttachedPromise = observerSpace.cursors.channel!.whenState('attached');
221219

222220
await Promise.all([performerCursorsChannelObserverPresentPromise, observerCursorsChannelAttachedPromise]);
223221

0 commit comments

Comments
 (0)