Skip to content

Commit a341f8a

Browse files
committed
addtests
1 parent df5daf8 commit a341f8a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

feature-main/src/test/java/com/hoc/flowmvi/ui/main/MainVMTest.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,30 @@ class MainVMTest : BaseMviViewModelTest<
206206
delayAfterDispatchingIntents = Duration.milliseconds(100),
207207
) { coVerify(exactly = 0) { refreshGetUsersUseCase() } }
208208
}
209+
210+
@Test
211+
fun test_withRefreshIntent_ignoredWhenHavingError() {
212+
val ioException = IOException()
213+
test(
214+
vmProducer = {
215+
every { getUserUseCase() } returns flow { throw ioException }
216+
coEvery { refreshGetUsersUseCase() } returns Unit
217+
vm
218+
},
219+
intentsBeforeCollecting = flowOf(ViewIntent.Initial),
220+
intents = flowOf(ViewIntent.Refresh),
221+
expectedStates = listOf(
222+
ViewState(
223+
userItems = emptyList(),
224+
isLoading = false,
225+
error = ioException,
226+
isRefreshing = false,
227+
)
228+
),
229+
expectedEvents = listOf(
230+
SingleEvent.GetUsersError(ioException),
231+
),
232+
delayAfterDispatchingIntents = Duration.milliseconds(100),
233+
) { coVerify(exactly = 0) { refreshGetUsersUseCase() } }
234+
}
209235
}

0 commit comments

Comments
 (0)