Skip to content

Commit

Permalink
refactor to helper utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Risch authored and Alex Risch committed Mar 2, 2024
1 parent 30c7aea commit 90ea7e3
Showing 1 changed file with 18 additions and 33 deletions.
51 changes: 18 additions & 33 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import RNFS from 'react-native-fs'
import { DecodedMessage } from 'xmtp-react-native-sdk/lib/DecodedMessage'

import { Test, assert, delayToPropogate, isIos } from './test-utils'
import {
Test,
assert,
createClients,
delayToPropogate,
isIos,
} from './test-utils'
import {
Client,
Conversation,
Expand Down Expand Up @@ -44,7 +50,9 @@ test('can delete a local database', async () => {
await client.conversations.syncGroups()
assert(
(await client.conversations.listGroups()).length === 1,
`should have a group size of 1 but was ${(await client.conversations.listGroups()).length}`
`should have a group size of 1 but was ${
(await client.conversations.listGroups()).length
}`
)

await client.deleteLocalDatabase()
Expand All @@ -56,7 +64,9 @@ test('can delete a local database', async () => {
await client.conversations.syncGroups()
assert(
(await client.conversations.listGroups()).length === 0,
`should have a group size of 0 but was ${(await client.conversations.listGroups()).length}`
`should have a group size of 0 but was ${
(await client.conversations.listGroups()).length
}`
)

return true
Expand Down Expand Up @@ -1011,12 +1021,7 @@ test('can streamAll from multiple clients', async () => {
})

test('can streamAll from multiple clients - swapped orderring', async () => {
const bo = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const [alix, bo, caro] = await createClients(3)

// Setup stream alls
const allBoConversations: any[] = []
Expand Down Expand Up @@ -1050,12 +1055,7 @@ test('can streamAll from multiple clients - swapped orderring', async () => {
})

test('can streamAllMessages from multiple clients', async () => {
const bo = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const [alix, bo, caro] = await createClients(3)

// Setup stream
const allBoMessages: any[] = []
Expand Down Expand Up @@ -1088,12 +1088,7 @@ test('can streamAllMessages from multiple clients', async () => {
})

test('can streamAllMessages from multiple clients - swapped', async () => {
const bo = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const [alix, bo, caro] = await createClients(3)

// Setup stream
const allBoMessages: any[] = []
Expand Down Expand Up @@ -1129,12 +1124,7 @@ test('can streamAllMessages from multiple clients - swapped', async () => {
})

test('can stream all group Messages from multiple clients', async () => {
const bo = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const [alix, bo, caro] = await createClients(3)

// Setup stream
const allAlixMessages: DecodedMessage[] = []
Expand Down Expand Up @@ -1180,12 +1170,7 @@ test('can stream all group Messages from multiple clients', async () => {
})

test('can stream all group Messages from multiple clients - swapped', async () => {
const bo = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const alix = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const caro = await Client.createRandom({ env: 'local', enableAlphaMls: true })
await delayToPropogate()
const [alix, bo, caro] = await createClients(3)

// Setup stream
const allAlixMessages: DecodedMessage[] = []
Expand Down

0 comments on commit 90ea7e3

Please sign in to comment.