diff --git a/example/src/tests/groupTests.ts b/example/src/tests/groupTests.ts index 533df4c18..fa2099819 100644 --- a/example/src/tests/groupTests.ts +++ b/example/src/tests/groupTests.ts @@ -3,7 +3,7 @@ import { Platform } from 'expo-modules-core' import RNFS from 'react-native-fs' import { DecodedMessage } from 'xmtp-react-native-sdk/lib/DecodedMessage' -import { Test, assert, createClients, delayToPropogate } from './test-utils' +import { Test, assert, createClients, createGroups, delayToPropogate } from './test-utils' import { Client, Conversation, @@ -927,7 +927,7 @@ test('can cancel streams', async () => { assert( messageCallbacks === 1, - 'message stream should have received 1 message' + `message stream should have received 1 message but recieved ${messageCallbacks}` ) await bo.conversations.cancelStreamAllMessages() @@ -941,7 +941,7 @@ test('can cancel streams', async () => { assert( messageCallbacks === 1, - 'message stream should still only received 1 message' + `message stream should still only received 1 message but recieved ${messageCallbacks}` ) await bo.conversations.streamAllMessages(async () => { @@ -949,11 +949,11 @@ test('can cancel streams', async () => { }, true) await group.send('hello') - await delayToPropogate() + await delayToPropogate(10000) assert( messageCallbacks === 2, - 'message stream should have received 2 message' + `message stream should have received 2 message but recieved ${messageCallbacks}` ) return true @@ -2171,7 +2171,7 @@ test('can create new installation without breaking group', async () => { test('can list many groups members in parallel', async () => { const [alix, bo] = await createClients(2) - const groups: Group[] = await createGroups(alix, [bo], 20, 0) + const groups: Group[] = await createGroups(alix, [bo], 20) try { await Promise.all(groups.slice(0, 10).map((g) => g.membersList())) @@ -2190,7 +2190,7 @@ test('can list many groups members in parallel', async () => { test('can sync all groups', async () => { const [alix, bo] = await createClients(2) - const groups: Group[] = await createGroups(alix, [bo], 50, 0) + const groups: Group[] = await createGroups(alix, [bo], 50) const alixGroup = groups[0] await bo.conversations.syncGroups() diff --git a/example/src/tests/test-utils.ts b/example/src/tests/test-utils.ts index ce7c2209b..43d10b586 100644 --- a/example/src/tests/test-utils.ts +++ b/example/src/tests/test-utils.ts @@ -1,5 +1,5 @@ import { Platform } from 'expo-modules-core' -import { Client, GroupUpdatedCodec } from 'xmtp-react-native-sdk' +import { Client, GroupUpdatedCodec, Group } from 'xmtp-react-native-sdk' export type Test = { name: string @@ -65,3 +65,21 @@ export async function createV3TestingClients(): Promise { clients.push(alix, bo, caro) return clients } + +export async function createGroups( + client: Client, + peers: Client[], + numGroups: number +): Promise { + const groups = [] + const addresses: string[] = peers.map((client) => client.address) + for (let i = 0; i < numGroups; i++) { + const group = await client.conversations.newGroup(addresses, { + name: `group ${i}`, + imageUrlSquare: `www.group${i}.com`, + description: `group ${i}`, + }) + groups.push(group) + } + return groups +}