From 740591cd38a01d8bf469cac3d78cf162e4a71c89 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL <46314705+mnaturel@users.noreply.github.com> Date: Fri, 30 Dec 2022 17:31:23 +0100 Subject: [PATCH] Updating unit tests --- .../roomprofile/polls/RoomPollsViewModelTest.kt | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/vector/src/test/java/im/vector/app/features/roomprofile/polls/RoomPollsViewModelTest.kt b/vector/src/test/java/im/vector/app/features/roomprofile/polls/RoomPollsViewModelTest.kt index 0dce2dd6e0..9cca32c5e6 100644 --- a/vector/src/test/java/im/vector/app/features/roomprofile/polls/RoomPollsViewModelTest.kt +++ b/vector/src/test/java/im/vector/app/features/roomprofile/polls/RoomPollsViewModelTest.kt @@ -23,7 +23,6 @@ import io.mockk.every import io.mockk.mockk import io.mockk.verify import kotlinx.coroutines.flow.flowOf -import org.amshove.kluent.shouldNotBeNull import org.junit.Rule import org.junit.Test @@ -45,28 +44,22 @@ class RoomPollsViewModelTest { } @Test - fun `given SetFilter action when handle then useCase is called with given filter and viewState is updated`() { + fun `given viewModel when created then polls list is observed and viewState is updated`() { // Given - val filter = RoomPollsFilterType.ACTIVE - val action = RoomPollsAction.SetFilter(filter = filter) val polls = listOf(givenAPollSummary()) - every { fakeGetPollsUseCase.execute(any()) } returns flowOf(polls) - val viewModel = createViewModel() + every { fakeGetPollsUseCase.execute() } returns flowOf(polls) val expectedViewState = initialState.copy(polls = polls) // When + val viewModel = createViewModel() val viewModelTest = viewModel.test() - viewModel.pollsCollectionJob = null - viewModel.handle(action) // Then viewModelTest .assertLatestState(expectedViewState) .finish() - viewModel.pollsCollectionJob.shouldNotBeNull() verify { - viewModel.pollsCollectionJob?.cancel() - fakeGetPollsUseCase.execute(filter) + fakeGetPollsUseCase.execute() } }