Skip to content

Commit

Permalink
[ECO-5082] chore: add sandbox for presence
Browse files Browse the repository at this point in the history
  • Loading branch information
ttypic committed Nov 13, 2024
1 parent 8658ae7 commit 2297f70
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions chat-android/src/test/java/com/ably/chat/SandboxTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
import org.junit.runners.model.MultipleFailureException.assertEmpty
import io.ably.lib.types.ClientOptions as PubSubClientOptions

class SandboxTest {
Expand All @@ -24,11 +25,23 @@ class SandboxTest {
}

@Test
fun basicIntegrationTest() = runTest {
fun `should return empty list of presence members if nobody is entered`() = runTest {
val chatClient = createSandboxChatClient(sandbox.apiKey)
val room = chatClient.rooms.get("basketball")
room.attach()
assertEquals(ChannelState.attached, room.messages.channel.state)
val members = room.presence.get()
assertEquals(0, members.size)
}

@Test
fun `should return yourself as presence member after you entered`() = runTest {
val chatClient = createSandboxChatClient(sandbox.apiKey)
val room = chatClient.rooms.get("basketball")
room.attach()
room.presence.enter()
val members = room.presence.get()
assertEquals(1, members.size)
assertEquals("sandbox-client", members.first().clientId)
}
}

Expand Down

0 comments on commit 2297f70

Please sign in to comment.