diff --git a/bindings_node/Cargo.toml b/bindings_node/Cargo.toml index 12ababf3a..8cc4ee49e 100644 --- a/bindings_node/Cargo.toml +++ b/bindings_node/Cargo.toml @@ -10,6 +10,7 @@ crate-type = ["cdylib"] # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix hex.workspace = true napi = { version = "2.12.2", default-features = false, features = [ + "napi4", "napi6", "async", ] } diff --git a/bindings_node/test/Client.test.ts b/bindings_node/test/Client.test.ts index 726429ab6..ee10c30bc 100644 --- a/bindings_node/test/Client.test.ts +++ b/bindings_node/test/Client.test.ts @@ -6,6 +6,7 @@ import { createRegisteredClient, createUser, encodeTextMessage, + sleep, } from '@test/helpers' import { ConsentEntityType, @@ -257,7 +258,7 @@ describe('Client', () => { }) describe('Streams', () => { - it.only('should stream all messages', async () => { + it('should stream all messages', async () => { const user = createUser() const client1 = await createRegisteredClient(user) @@ -272,6 +273,7 @@ describe('Streams', () => { const group2 = client2.conversations().findGroupById(group.id()) let messages = new Array() + client2.conversations().syncAllConversations() let stream = client2.conversations().streamAllMessages((msg) => { console.log('Message', msg) messages.push(msg) @@ -281,6 +283,7 @@ describe('Streams', () => { group.send(encodeTextMessage('Test2')) group.send(encodeTextMessage('Test3')) group.send(encodeTextMessage('Test4')) + await sleep(1000) await stream.endAndWait() expect(messages.length).toBe(4) }) diff --git a/bindings_node/test/helpers.ts b/bindings_node/test/helpers.ts index 7a417317f..90f61189a 100644 --- a/bindings_node/test/helpers.ts +++ b/bindings_node/test/helpers.ts @@ -80,3 +80,9 @@ export const encodeTextMessage = (text: string) => { content: new TextEncoder().encode(text), } } + +export function sleep(ms) { + return new Promise((resolve) => { + setTimeout(resolve, ms) + }) +}