From 0d9b91145bb69fef9c8b673f35e9398a6d441d0c Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Mon, 17 Jun 2024 06:40:52 -0700 Subject: [PATCH] Add test for metadata codec (#260) * add test for codecc * fix linter --- .../xmtp/android/library/GroupUpdatedTest.kt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/library/src/androidTest/java/org/xmtp/android/library/GroupUpdatedTest.kt b/library/src/androidTest/java/org/xmtp/android/library/GroupUpdatedTest.kt index 2532936af..0772bbea7 100644 --- a/library/src/androidTest/java/org/xmtp/android/library/GroupUpdatedTest.kt +++ b/library/src/androidTest/java/org/xmtp/android/library/GroupUpdatedTest.kt @@ -142,4 +142,36 @@ class GroupUpdatedTest { assertEquals(messages.size, 1) assert(messages.first().fallbackContent.isBlank()) } + + @Test + fun testCanUpdateGroupName() { + Client.register(codec = GroupUpdatedCodec()) + + val group = runBlocking { + alixClient.conversations.newGroup( + listOf( + bo.walletAddress, + caro.walletAddress + ), + groupName = "Start Name" + ) + } + var messages = group.messages() + assertEquals(messages.size, 1) + runBlocking { + group.updateGroupName("Group Name") + messages = group.messages() + assertEquals(messages.size, 2) + + val content: GroupUpdated? = messages.first().content() + assertEquals( + "Start Name", + content?.metadataFieldChangesList?.first()?.oldValue + ) + assertEquals( + "Group Name", + content?.metadataFieldChangesList?.first()?.newValue + ) + } + } }