Skip to content

Commit

Permalink
write a test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Dec 18, 2024
1 parent 55eb129 commit 2209ff0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
30 changes: 30 additions & 0 deletions example/src/tests/conversationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,36 @@ test('can filter conversations by consent', async () => {
return true
})

test('can filter sync all by consent', async () => {
const [alixClient, boClient, caroClient] = await createClients(3)

await boClient.conversations.newGroup([alixClient.address])
const otherGroup = await alixClient.conversations.newGroup([boClient.address])
await boClient.conversations.findOrCreateDm(alixClient.address)
await caroClient.conversations.findOrCreateDm(boClient.address)
await boClient.conversations.sync()
await boClient.conversations.findDmByInboxId(caroClient.inboxId)
await boClient.conversations.findGroup(otherGroup.id)

const boConvos = await boClient.conversations.syncAllConversations()
const boConvosFilteredAllowed =
await boClient.conversations.syncAllConversations('allowed')
const boConvosFilteredUnknown =
await boClient.conversations.syncAllConversations('unknown')

assert(boConvos === 4, `Conversation length should be 4 but was ${boConvos}`)
assert(
boConvosFilteredAllowed === 2,
`Conversation length should be 2 but was ${boConvosFilteredAllowed}`
)
assert(
boConvosFilteredUnknown === 2,
`Conversation length should be 2 but was ${boConvosFilteredUnknown}`
)

return true
})

test('can list conversations with params', async () => {
const [alixClient, boClient, caroClient] = await createClients(3)

Expand Down
11 changes: 8 additions & 3 deletions ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,8 @@ public class XMTPModule: Module {
} else {
consent = nil
}
return try await client.conversations.syncAllConversations(consentState: consent)
return try await client.conversations.syncAllConversations(
consentState: consent)
}

AsyncFunction("syncConversation") {
Expand Down Expand Up @@ -2039,7 +2040,9 @@ public class XMTPModule: Module {
throw Error.noClient
}

guard let converation = try await client.findConversation(conversationId: id)
guard
let converation = try await client.findConversation(
conversationId: id)
else {
return
}
Expand Down Expand Up @@ -2083,7 +2086,9 @@ public class XMTPModule: Module {
throw Error.noClient
}

guard let converation = try await client.findConversation(conversationId: id)
guard
let converation = try await client.findConversation(
conversationId: id)
else {
return
}
Expand Down

0 comments on commit 2209ff0

Please sign in to comment.