Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
saleniuk committed Mar 4, 2024
1 parent 0c91ae6 commit 067daac
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ package com.wire.android.ui.home.conversations.typing
import androidx.lifecycle.SavedStateHandle
import app.cash.turbine.test
import com.wire.android.config.CoroutineTestExtension
import com.wire.android.config.NavigationTestExtension
import com.wire.android.config.ScopedArgsTestExtension
import com.wire.android.di.scopedArgs
import com.wire.android.framework.TestConversation
import com.wire.android.ui.home.conversations.ConversationNavArgs
import com.wire.android.ui.home.conversations.details.participants.model.UIParticipant
import com.wire.android.ui.home.conversations.typing.TypingIndicatorViewModelTest.Arrangement.Companion.expectedUIParticipant
import com.wire.android.ui.home.conversations.usecase.ObserveUsersTypingInConversationUseCase
import com.wire.android.ui.navArgs
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.user.UserId
import io.mockk.MockKAnnotations
import io.mockk.coEvery
Expand All @@ -43,7 +41,7 @@ import org.junit.jupiter.api.extension.ExtendWith

@OptIn(ExperimentalCoroutinesApi::class)
@ExtendWith(CoroutineTestExtension::class)
@ExtendWith(NavigationTestExtension::class)
@ExtendWith(ScopedArgsTestExtension::class)
class TypingIndicatorViewModelTest {

@Test
Expand Down Expand Up @@ -72,16 +70,15 @@ class TypingIndicatorViewModelTest {

init {
MockKAnnotations.init(this, relaxUnitFun = true)
every { savedStateHandle.navArgs<ConversationId>() } returns TestConversation.ID
every { savedStateHandle.navArgs<ConversationNavArgs>() } returns ConversationNavArgs(conversationId = TestConversation.ID)
every { savedStateHandle.scopedArgs<TypingIndicatorArgs>() } returns TypingIndicatorArgs(conversationId = TestConversation.ID)
coEvery { observeUsersTypingInConversation(eq(TestConversation.ID)) } returns flowOf(emptyList())
}

fun withParticipantsTyping(usersTyping: List<UIParticipant> = emptyList()) = apply {
coEvery { observeUsersTypingInConversation(eq(TestConversation.ID)) } returns flowOf(usersTyping)
}

fun arrange() = this to TypingIndicatorViewModel(observeUsersTypingInConversation, savedStateHandle)
fun arrange() = this to TypingIndicatorViewModelImpl(observeUsersTypingInConversation, savedStateHandle)

companion object {
val expectedUIParticipant = UIParticipant(
Expand Down

0 comments on commit 067daac

Please sign in to comment.