Skip to content

Commit

Permalink
✅ Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
iujames committed Oct 21, 2024
1 parent 2df00ec commit a436eef
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.appcues.ui.presentation

import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.compose.ui.geometry.Offset
import androidx.lifecycle.viewModelScope
import com.appcues.AppcuesCoroutineScope
import com.appcues.action.ActionProcessor
Expand Down Expand Up @@ -68,6 +69,8 @@ internal class AppcuesViewModelTest {

private val onDismiss: () -> Unit = mockk(relaxed = true)

private val tapPassThroughHandler: (Offset) -> Unit = mockk(relaxed = true)

private lateinit var viewModel: AppcuesViewModel

private val uiStates = arrayListOf<UIState>()
Expand All @@ -78,7 +81,14 @@ internal class AppcuesViewModelTest {
fun setup() {
Dispatchers.setMain(UnconfinedTestDispatcher())

viewModel = AppcuesViewModel(renderContext, coroutineScope, experienceRenderer, actionProcessor, onDismiss).apply {
viewModel = AppcuesViewModel(
renderContext = renderContext,
coroutineScope = coroutineScope,
experienceRenderer = experienceRenderer,
actionProcessor = actionProcessor,
onDismiss = onDismiss,
tapPassThroughHandler = tapPassThroughHandler
).apply {
stateJob = viewModelScope.launch { uiState.collect { uiStates.add(it) } }
}

Expand Down Expand Up @@ -106,7 +116,7 @@ internal class AppcuesViewModelTest {
coEvery { getStateFlow(renderContext) } returns null
}
// WHEN
viewModel = AppcuesViewModel(renderContext, coroutineScope, experienceRenderer, actionProcessor, onDismiss)
viewModel = AppcuesViewModel(renderContext, coroutineScope, experienceRenderer, actionProcessor, onDismiss, tapPassThroughHandler)
// WHEN
verifySequence { onDismiss.invoke() }
}
Expand Down

0 comments on commit a436eef

Please sign in to comment.