@@ -3,7 +3,6 @@ package org.xmtp.android.library
3
3
import androidx.test.ext.junit.runners.AndroidJUnit4
4
4
import androidx.test.platform.app.InstrumentationRegistry
5
5
import app.cash.turbine.test
6
- import kotlinx.coroutines.ExperimentalCoroutinesApi
7
6
import kotlinx.coroutines.runBlocking
8
7
import org.junit.Assert.assertEquals
9
8
import org.junit.Assert.assertThrows
@@ -113,6 +112,45 @@ class GroupTest {
113
112
)
114
113
}
115
114
115
+ @Test
116
+ fun testCanRemoveGroupMembersWhenNotCreator () {
117
+ boClient.conversations.newGroup(
118
+ listOf (
119
+ alix.walletAddress,
120
+ caro.walletAddress
121
+ )
122
+ )
123
+ runBlocking { alixClient.conversations.syncGroups() }
124
+ val group = alixClient.conversations.listGroups().first()
125
+ group.removeMembers(listOf (caro.walletAddress))
126
+ assertEquals(
127
+ group.memberAddresses().sorted(),
128
+ listOf (
129
+ alix.walletAddress.lowercase(),
130
+ bo.walletAddress.lowercase()
131
+ ).sorted()
132
+ )
133
+ }
134
+
135
+ @Test
136
+ fun testIsActiveReturnsCorrectly () {
137
+ val group = boClient.conversations.newGroup(
138
+ listOf (
139
+ alix.walletAddress,
140
+ caro.walletAddress
141
+ )
142
+ )
143
+ runBlocking { caroClient.conversations.syncGroups() }
144
+ val caroGroup = caroClient.conversations.listGroups().first()
145
+ runBlocking { caroGroup.sync() }
146
+ assert (caroGroup.isActive())
147
+ assert (group.isActive())
148
+ group.removeMembers(listOf (caro.walletAddress))
149
+ runBlocking { caroGroup.sync() }
150
+ assert (group.isActive())
151
+ assert (! caroGroup.isActive())
152
+ }
153
+
116
154
@Test
117
155
fun testCanListGroups () {
118
156
boClient.conversations.newGroup(listOf (alix.walletAddress))
@@ -200,11 +238,9 @@ class GroupTest {
200
238
assertEquals(ReactionSchema .Unicode , content?.schema)
201
239
}
202
240
203
- @OptIn(ExperimentalCoroutinesApi ::class )
204
241
@Test
205
242
fun testCanStreamGroupMessages () = kotlinx.coroutines.test.runTest {
206
243
val group = boClient.conversations.newGroup(listOf (alix.walletAddress.lowercase()))
207
-
208
244
group.streamMessages().test {
209
245
group.send(" hi" )
210
246
assertEquals(" hi" , awaitItem().body)
@@ -213,7 +249,6 @@ class GroupTest {
213
249
}
214
250
}
215
251
216
- @OptIn(ExperimentalCoroutinesApi ::class )
217
252
@Test
218
253
fun testCanStreamDecryptedGroupMessages () = kotlinx.coroutines.test.runTest {
219
254
val group = boClient.conversations.newGroup(listOf (alix.walletAddress))
@@ -226,7 +261,6 @@ class GroupTest {
226
261
}
227
262
}
228
263
229
- @OptIn(ExperimentalCoroutinesApi ::class )
230
264
@Test
231
265
fun testCanStreamGroups () = kotlinx.coroutines.test.runTest {
232
266
boClient.conversations.streamGroups().test {
@@ -239,7 +273,6 @@ class GroupTest {
239
273
}
240
274
}
241
275
242
- @OptIn(ExperimentalCoroutinesApi ::class )
243
276
@Test
244
277
fun testCanStreamGroupsAndConversations () = kotlinx.coroutines.test.runTest {
245
278
boClient.conversations.streamAll().test {
0 commit comments