From b8b37e85d9365c7e7c44f48d557d6726b5a35bd4 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 15 Dec 2023 21:08:50 +0100 Subject: [PATCH] Fix more test. --- .../impl/history/PollHistoryPresenterTest.kt | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt b/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt index 172ec5fa28..39494e1f34 100644 --- a/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt +++ b/features/poll/impl/src/test/kotlin/io/element/android/features/poll/impl/history/PollHistoryPresenterTest.kt @@ -52,14 +52,15 @@ class PollHistoryPresenterTest { @get:Rule val warmUpRule = WarmUpRule() - private val room = FakeMatrixRoom( - matrixTimeline = aPollTimeline( - polls = mapOf( - AN_EVENT_ID to anOngoingPollContent(), - AN_EVENT_ID_2 to anEndedPollContent() - ) + private val timeline = aPollTimeline( + polls = mapOf( + AN_EVENT_ID to anOngoingPollContent(), + AN_EVENT_ID_2 to anEndedPollContent() ) ) + private val room = FakeMatrixRoom( + matrixTimeline = timeline + ) @Test fun `present - initial states`() = runTest { @@ -134,10 +135,14 @@ class PollHistoryPresenterTest { presenter.present() }.test { consumeItemsUntilPredicate { - it.pollHistoryItems.size == 2 && !it.isLoading - }.last().also { state -> - state.eventSink(PollHistoryEvents.LoadMore) + it.pollHistoryItems.size == 2 } + timeline.updatePaginationState { + copy(isBackPaginating = false) + } + val loadedState = awaitItem() + assertThat(loadedState.isLoading).isFalse() + loadedState.eventSink(PollHistoryEvents.LoadMore) consumeItemsUntilPredicate { it.isLoading }