Adds tests for selectedSpaceFlow and activeSpaceId
This commit is contained in:
parent
f770ae0653
commit
9a649b6093
|
@ -24,6 +24,8 @@ import im.vector.app.test.fakes.FakeUiStateRepository
|
|||
import io.mockk.every
|
||||
import io.mockk.justRun
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.amshove.kluent.shouldBe
|
||||
import org.amshove.kluent.shouldBeEqualTo
|
||||
import org.junit.Before
|
||||
|
@ -113,4 +115,29 @@ internal class AppStateHandlerImplTest {
|
|||
|
||||
backstack.size shouldBe 0
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when setCurrentSpace, then space is emitted to selectedSpaceFlow`() = runTest {
|
||||
appStateHandler.setCurrentSpace(spaceId, session)
|
||||
|
||||
val currentSpace = appStateHandler.getSelectedSpaceFlow().first().orNull()
|
||||
|
||||
currentSpace shouldBeEqualTo spaceSummary
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given current space exists, when getSafeActiveSpaceId, then return current space id`() {
|
||||
appStateHandler.setCurrentSpace(spaceId, session)
|
||||
|
||||
val activeSpaceId = appStateHandler.getSafeActiveSpaceId()
|
||||
|
||||
activeSpaceId shouldBeEqualTo spaceId
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given current space doesn't exist, when getSafeActiveSpaceId, then return current null`() {
|
||||
val activeSpaceId = appStateHandler.getSafeActiveSpaceId()
|
||||
|
||||
activeSpaceId shouldBe null
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue