File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
feature-main/src/test/java/com/hoc/flowmvi/ui/main
mvi/mvi-testing/src/main/java/com/flowmvi/mvi_testing Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import io.mockk.mockk
12
12
import io.mockk.verify
13
13
import kotlinx.coroutines.ExperimentalCoroutinesApi
14
14
import kotlinx.coroutines.FlowPreview
15
+ import kotlinx.coroutines.flow.emptyFlow
15
16
import kotlinx.coroutines.flow.flow
16
17
import kotlinx.coroutines.flow.flowOf
17
18
import java.io.IOException
@@ -232,4 +233,18 @@ class MainVMTest : BaseMviViewModelTest<
232
233
delayAfterDispatchingIntents = Duration .milliseconds(100 ),
233
234
) { coVerify(exactly = 0 ) { refreshGetUsersUseCase() } }
234
235
}
236
+
237
+ @Test
238
+ fun test_withRetryIntent_ignoredWhenHavingNoError () {
239
+ test(
240
+ vmProducer = {
241
+ every { getUserUseCase() } returns emptyFlow()
242
+ vm
243
+ },
244
+ intents = flowOf(ViewIntent .Retry ),
245
+ expectedStates = listOf (ViewState .initial()),
246
+ expectedEvents = emptyList(),
247
+ delayAfterDispatchingIntents = Duration .milliseconds(100 ),
248
+ ) { coVerify(exactly = 0 ) { getUserUseCase() } }
249
+ }
235
250
}
Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ abstract class BaseMviViewModelTest<
46
46
intents : Flow <I >,
47
47
expectedStates : List <S >,
48
48
expectedEvents : List <E >,
49
- delayAfterDispatchingIntents : Duration = Duration .milliseconds(50),
49
+ delayAfterDispatchingIntents : Duration = Duration .ZERO ,
50
+ logging : Boolean = true,
50
51
intentsBeforeCollecting : Flow <I >? = null,
51
52
otherAssertions : (suspend () -> Unit )? = null,
52
53
) = testDispatcher.runBlockingTest {
@@ -62,8 +63,10 @@ abstract class BaseMviViewModelTest<
62
63
intents.collect { vm.processIntent(it) }
63
64
delay(delayAfterDispatchingIntents)
64
65
65
- println (states)
66
- println (events)
66
+ if (logging) {
67
+ println (states)
68
+ println (events)
69
+ }
67
70
68
71
assertEquals(expectedStates.size, states.size)
69
72
assertContentEquals(
You can’t perform that action at this time.
0 commit comments