File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
feature-main/src/test/java/com/hoc/flowmvi/ui/main Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -286,4 +286,45 @@ class MainVMTest : BaseMviViewModelTest<
286
286
),
287
287
) { verify(exactly = 2 ) { getUserUseCase() } }
288
288
}
289
+
290
+ @Test
291
+ fun test_withRetryIntentWhenSuccess_returnsErrorState () {
292
+ val ioException1 = IOException ()
293
+ val ioException2 = IOException ()
294
+ test(
295
+ vmProducer = {
296
+ every { getUserUseCase() } returnsMany listOf (
297
+ flow { throw ioException1 },
298
+ flow { throw ioException2 },
299
+ )
300
+ vm
301
+ },
302
+ intentsBeforeCollecting = flowOf(ViewIntent .Initial ),
303
+ intents = flowOf(ViewIntent .Retry ),
304
+ expectedStates = listOf (
305
+ ViewState (
306
+ userItems = emptyList(),
307
+ isLoading = false ,
308
+ error = ioException1,
309
+ isRefreshing = false ,
310
+ ),
311
+ ViewState (
312
+ userItems = emptyList(),
313
+ isLoading = true ,
314
+ error = null ,
315
+ isRefreshing = false ,
316
+ ),
317
+ ViewState (
318
+ userItems = emptyList(),
319
+ isLoading = false ,
320
+ error = ioException2,
321
+ isRefreshing = false ,
322
+ )
323
+ ),
324
+ expectedEvents = listOf (
325
+ SingleEvent .GetUsersError (ioException1),
326
+ SingleEvent .GetUsersError (ioException2),
327
+ ),
328
+ ) { verify(exactly = 2 ) { getUserUseCase() } }
329
+ }
289
330
}
You can’t perform that action at this time.
0 commit comments