Skip to content

Commit 0f0b254

Browse files
committed
addtests
1 parent fc5a2d6 commit 0f0b254

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,45 @@ class MainVMTest : BaseMviViewModelTest<
286286
),
287287
) { verify(exactly = 2) { getUserUseCase() } }
288288
}
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+
}
289330
}

0 commit comments

Comments
 (0)