File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
feature-main/src/test/java/com/hoc/flowmvi/ui/main Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -247,4 +247,43 @@ class MainVMTest : BaseMviViewModelTest<
247
247
delayAfterDispatchingIntents = Duration .milliseconds(100 ),
248
248
) { coVerify(exactly = 0 ) { getUserUseCase() } }
249
249
}
250
+
251
+ @Test
252
+ fun test_withRetryIntentWhenSuccess_returnsUserItems () {
253
+ val ioException = IOException ()
254
+ test(
255
+ vmProducer = {
256
+ every { getUserUseCase() } returnsMany listOf (
257
+ flow { throw ioException },
258
+ flowOf(USERS ),
259
+ )
260
+ vm
261
+ },
262
+ intentsBeforeCollecting = flowOf(ViewIntent .Initial ),
263
+ intents = flowOf(ViewIntent .Retry ),
264
+ expectedStates = listOf (
265
+ ViewState (
266
+ userItems = emptyList(),
267
+ isLoading = false ,
268
+ error = ioException,
269
+ isRefreshing = false ,
270
+ ),
271
+ ViewState (
272
+ userItems = emptyList(),
273
+ isLoading = true ,
274
+ error = null ,
275
+ isRefreshing = false ,
276
+ ),
277
+ ViewState (
278
+ userItems = USER_ITEMS ,
279
+ isLoading = false ,
280
+ error = null ,
281
+ isRefreshing = false ,
282
+ )
283
+ ),
284
+ expectedEvents = listOf (
285
+ SingleEvent .GetUsersError (ioException),
286
+ ),
287
+ ) { verify(exactly = 2 ) { getUserUseCase() } }
288
+ }
250
289
}
You can’t perform that action at this time.
0 commit comments