Skip to content

Commit

Permalink
add test for filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Apr 18, 2024
1 parent 46a433d commit ddb15c4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions library/src/androidTest/java/org/xmtp/android/library/GroupTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.xmtp.android.library.codecs.Reaction
import org.xmtp.android.library.codecs.ReactionAction
import org.xmtp.android.library.codecs.ReactionCodec
import org.xmtp.android.library.codecs.ReactionSchema
import org.xmtp.android.library.messages.MessageDeliveryStatus
import org.xmtp.android.library.messages.PrivateKey
import org.xmtp.android.library.messages.PrivateKeyBuilder
import org.xmtp.android.library.messages.walletAddress
Expand Down Expand Up @@ -334,6 +335,7 @@ class GroupTest {
runBlocking { group.sync() }
assertEquals(group.messages().first().body, "gm")
assertEquals(group.messages().first().id, messageId)
assertEquals(group.messages().first().deliveryStatus, MessageDeliveryStatus.PUBLISHED)
assertEquals(group.messages().size, 3)

runBlocking { alixClient.conversations.syncGroups() }
Expand All @@ -343,6 +345,28 @@ class GroupTest {
assertEquals(sameGroup.messages().first().body, "gm")
}

@Test
fun testCanListGroupMessages() {
val group = runBlocking { boClient.conversations.newGroup(listOf(alix.walletAddress)) }
runBlocking {
group.send("howdy")
group.send("gm")
}

assertEquals(group.messages().size, 3)
assertEquals(group.messages(deliveryStatus = MessageDeliveryStatus.UNPUBLISHED).size, 2)
assertEquals(group.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 1)
runBlocking { group.sync() }
assertEquals(group.messages().size, 3)
assertEquals(group.messages(deliveryStatus = MessageDeliveryStatus.UNPUBLISHED).size, 0)
assertEquals(group.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 3)

runBlocking { alixClient.conversations.syncGroups() }
val sameGroup = runBlocking { alixClient.conversations.listGroups().last() }
runBlocking { sameGroup.sync() }
assertEquals(sameGroup.messages(deliveryStatus = MessageDeliveryStatus.PUBLISHED).size, 2)
}

@Test
fun testCanSendContentTypesToGroup() {
Client.register(codec = ReactionCodec())
Expand Down

0 comments on commit ddb15c4

Please sign in to comment.