From 747467deb981e7438e9540bf17022f966112b7c9 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 13 Apr 2023 16:18:28 +0200 Subject: [PATCH] Fix test --- .../android/appnav/RoomFlowPresenterTest.kt | 62 ------------------- .../appnavstate/test/AppNavStateFixture.kt | 9 +-- 2 files changed, 5 insertions(+), 66 deletions(-) delete mode 100644 appnav/src/test/kotlin/io/element/android/appnav/RoomFlowPresenterTest.kt diff --git a/appnav/src/test/kotlin/io/element/android/appnav/RoomFlowPresenterTest.kt b/appnav/src/test/kotlin/io/element/android/appnav/RoomFlowPresenterTest.kt deleted file mode 100644 index 1347b0b24c..0000000000 --- a/appnav/src/test/kotlin/io/element/android/appnav/RoomFlowPresenterTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2023 New Vector Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.element.android.appnav - -import app.cash.molecule.RecompositionClock -import app.cash.molecule.moleculeFlow -import app.cash.turbine.test -import com.google.common.truth.Truth -import io.element.android.libraries.matrix.test.room.FakeMatrixRoom -import io.element.android.libraries.matrix.test.timeline.FakeMatrixTimeline -import kotlinx.coroutines.test.runTest -import org.junit.Test -import java.lang.IllegalStateException - -class RoomFlowPresenterTest { - - @Test - fun `present - fetches room members`() = runTest { - val fakeTimeline = FakeMatrixTimeline() - val room = FakeMatrixRoom(matrixTimeline = fakeTimeline) - val presenter = RoomFlowPresenter(room) - - Truth.assertThat(room.areMembersFetched).isFalse() - moleculeFlow(RecompositionClock.Immediate) { - presenter.present() - }.test { - Truth.assertThat(room.areMembersFetched).isTrue() - cancelAndIgnoreRemainingEvents() - } - } - - @Test - fun `present - recovers from error while fetching room members`() = runTest { - val fakeTimeline = FakeMatrixTimeline() - val room = FakeMatrixRoom(matrixTimeline = fakeTimeline).apply { - givenFetchMemberResult(Result.failure(IllegalStateException("Some error"))) - } - val presenter = RoomFlowPresenter(room) - - Truth.assertThat(room.areMembersFetched).isFalse() - moleculeFlow(RecompositionClock.Immediate) { - presenter.present() - }.test { - Truth.assertThat(room.areMembersFetched).isFalse() - cancelAndIgnoreRemainingEvents() - } - } -} diff --git a/services/appnavstate/test/src/main/kotlin/io/element/android/services/appnavstate/test/AppNavStateFixture.kt b/services/appnavstate/test/src/main/kotlin/io/element/android/services/appnavstate/test/AppNavStateFixture.kt index 20e872b803..0ac6526ee2 100644 --- a/services/appnavstate/test/src/main/kotlin/io/element/android/services/appnavstate/test/AppNavStateFixture.kt +++ b/services/appnavstate/test/src/main/kotlin/io/element/android/services/appnavstate/test/AppNavStateFixture.kt @@ -28,21 +28,22 @@ fun anAppNavigationState( spaceId: SpaceId? = MAIN_SPACE, roomId: RoomId? = null, threadId: ThreadId? = null, + owner: String = "a-owner", ): AppNavigationState { if (sessionId == null) { return AppNavigationState.Root } - val session = AppNavigationState.Session(sessionId) + val session = AppNavigationState.Session(owner, sessionId) if (spaceId == null) { return session } - val space = AppNavigationState.Space(spaceId, session) + val space = AppNavigationState.Space(owner, spaceId, session) if (roomId == null) { return space } - val room = AppNavigationState.Room(roomId, space) + val room = AppNavigationState.Room(owner, roomId, space) if (threadId == null) { return room } - return AppNavigationState.Thread(threadId, room) + return AppNavigationState.Thread(owner, threadId, room) }