Skip to content

Commit

Permalink
fix up the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Sep 29, 2024
1 parent 4fd09a0 commit 01aabd0
Showing 1 changed file with 47 additions and 46 deletions.
93 changes: 47 additions & 46 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
@@ -360,6 +360,53 @@ test('production MLS V3 client creation does not error', async () => {
return true
})

test('can cancel streams', async () => {
const [alix, bo] = await createClients(2)
let messageCallbacks = 0

await bo.conversations.streamAllMessages(async () => {
messageCallbacks++
}, true)

const group = await alix.conversations.newGroup([bo.address])
await group.send('hello')
await delayToPropogate()

assert(
messageCallbacks === 1,
`message stream should have received 1 message but recieved ${messageCallbacks}`
)

await bo.conversations.cancelStreamAllMessages()
await delayToPropogate()

await group.send('hello')
await group.send('hello')
await group.send('hello')

await delayToPropogate()

assert(
messageCallbacks === 1,
`message stream should still only received 1 message but recieved ${messageCallbacks}`
)

await bo.conversations.streamAllMessages(async () => {
messageCallbacks++
}, true)

Check warning on line 397 in example/src/tests/groupTests.ts

GitHub Actions / lint

Delete `··`
await delayToPropogate()
await group.send('hello')
await delayToPropogate()

assert(
messageCallbacks === 2,
`message stream should have received 2 message but recieved ${messageCallbacks}`
)

return true
})

test('group message delivery status', async () => {
const [alixClient, boClient] = await createClients(2)
const alixGroup = await alixClient.conversations.newGroup([boClient.address])
@@ -913,52 +960,6 @@ test('can remove and add members from a group by inbox id', async () => {
return true
})

test('can cancel streams', async () => {
const [alix, bo] = await createClients(2)
let messageCallbacks = 0

await bo.conversations.streamAllMessages(async () => {
messageCallbacks++
}, true)

const group = await alix.conversations.newGroup([bo.address])
await group.send('hello')
await delayToPropogate()

assert(
messageCallbacks === 1,
`message stream should have received 1 message but recieved ${messageCallbacks}`
)

await bo.conversations.cancelStreamAllMessages()
await delayToPropogate()

await group.send('hello')
await group.send('hello')
await group.send('hello')

await delayToPropogate()

assert(
messageCallbacks === 1,
`message stream should still only received 1 message but recieved ${messageCallbacks}`
)

await bo.conversations.streamAllMessages(async () => {
messageCallbacks++
}, true)

await group.send('hello')
await delayToPropogate(10000)

assert(
messageCallbacks === 2,
`message stream should have received 2 message but recieved ${messageCallbacks}`
)

return true
})

test('can stream both groups and messages at same time', async () => {
const [alix, bo] = await createClients(2)

0 comments on commit 01aabd0

Please sign in to comment.