Skip to content

Commit

Permalink
add a few more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 21, 2024
1 parent a0957e5 commit 7e37791
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions example/src/tests/groupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,3 +763,40 @@ test('can make a group with admin permissions', async () => {

return true
})

test('can paginate group messages', async () => {
// Create three MLS enabled Clients
const aliceClient = await Client.createRandom({
env: 'local',
enableAlphaMls: true,
})
const bobClient = await Client.createRandom({
env: 'local',
enableAlphaMls: true,
})

// Alice creates a group
const aliceGroup = await aliceClient.conversations.newGroup([
bobClient.address,
])

// Alice can send messages
await aliceGroup.send('hello, world')
await aliceGroup.send('gm')

const bobGroups = await bobClient.conversations.listGroups()
if (bobGroups.length !== 1) {
throw new Error(
'num groups for bob should be 1, but it is' + bobGroups.length
)
}
delayToPropogate()
// Bob can read messages from Alice
const bobMessages: DecodedMessage[] = await bobGroups[0].messages(false, 1)

if (bobMessages.length !== 1) {
throw Error(`Should limit just 1 message but was ${bobMessages.length}`)
}

return true
})
2 changes: 1 addition & 1 deletion src/lib/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class Group<
}

async messages(
skipSync = false,
skipSync: boolean = false,
limit?: number | undefined,
before?: number | Date | undefined,
after?: number | Date | undefined,
Expand Down

0 comments on commit 7e37791

Please sign in to comment.