Moves UiStateRepository stubbing to fake class

This commit is contained in:
ericdecanini 2022-07-21 10:38:31 +02:00
parent 1d77f99148
commit d8fdaf0477
2 changed files with 5 additions and 7 deletions

View file

@ -22,12 +22,10 @@ import im.vector.app.test.fakes.FakeAnalyticsTracker
import im.vector.app.test.fakes.FakeSession import im.vector.app.test.fakes.FakeSession
import im.vector.app.test.fakes.FakeUiStateRepository import im.vector.app.test.fakes.FakeUiStateRepository
import im.vector.app.test.fixtures.RoomSummaryFixture.aRoomSummary import im.vector.app.test.fixtures.RoomSummaryFixture.aRoomSummary
import io.mockk.justRun
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import org.amshove.kluent.shouldBe import org.amshove.kluent.shouldBe
import org.amshove.kluent.shouldBeEqualTo import org.amshove.kluent.shouldBeEqualTo
import org.junit.Before
import org.junit.Test import org.junit.Test
internal class SpaceStateHandlerImplTest { internal class SpaceStateHandlerImplTest {
@ -48,11 +46,6 @@ internal class SpaceStateHandlerImplTest {
analyticsTracker, analyticsTracker,
) )
@Before
fun setup() {
justRun { uiStateRepository.storeSelectedSpace(any(), any()) }
}
@Test @Test
fun `given selected space doesn't exist, when getCurrentSpace, then return null`() { fun `given selected space doesn't exist, when getCurrentSpace, then return null`() {
val currentSpace = spaceStateHandler.getCurrentSpace() val currentSpace = spaceStateHandler.getCurrentSpace()

View file

@ -17,12 +17,17 @@
package im.vector.app.test.fakes package im.vector.app.test.fakes
import im.vector.app.features.ui.UiStateRepository import im.vector.app.features.ui.UiStateRepository
import io.mockk.justRun
import io.mockk.mockk import io.mockk.mockk
import io.mockk.verify import io.mockk.verify
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
class FakeUiStateRepository : UiStateRepository by mockk() { class FakeUiStateRepository : UiStateRepository by mockk() {
init {
justRun { storeSelectedSpace(any(), any()) }
}
fun verifyStoreSelectedSpace(roomId: String, session: Session, inverse: Boolean = false) { fun verifyStoreSelectedSpace(roomId: String, session: Session, inverse: Boolean = false) {
verify(inverse = inverse) { storeSelectedSpace(roomId, session.sessionId) } verify(inverse = inverse) { storeSelectedSpace(roomId, session.sessionId) }
} }