Add assertThatAndStateTurbineConsumed and assertThatAndEffectTurbineConsumed for simpler test setup
This commit is contained in:
parent
f0632d6c9a
commit
c29bc90535
1 changed files with 30 additions and 0 deletions
|
@ -72,6 +72,36 @@ fun <T, STATE, EFFECT> assertThatAndMviTurbinesConsumed(
|
|||
turbines.effectTurbine.ensureAllEventsConsumed()
|
||||
}
|
||||
|
||||
/**
|
||||
* The `assertThatAndStateTurbineConsumed` function ensures that the assertion passed and
|
||||
* all events in the state turbine have been consumed.
|
||||
*/
|
||||
suspend fun <STATE, EFFECT> MviTurbines<STATE, EFFECT>.assertThatAndStateTurbineConsumed(
|
||||
assertion: Assert<STATE>.() -> Unit,
|
||||
) {
|
||||
assertThat(stateTurbine.awaitItem()).all {
|
||||
assertion()
|
||||
}
|
||||
|
||||
stateTurbine.ensureAllEventsConsumed()
|
||||
effectTurbine.ensureAllEventsConsumed()
|
||||
}
|
||||
|
||||
/**
|
||||
* The `assertThatAndEffectTurbineConsumed` function ensures that the assertion passed and
|
||||
* all events in the effect turbine have been consumed.
|
||||
*/
|
||||
suspend fun <STATE, EFFECT> MviTurbines<STATE, EFFECT>.assertThatAndEffectTurbineConsumed(
|
||||
assertion: Assert<EFFECT>.() -> Unit,
|
||||
) {
|
||||
assertThat(effectTurbine.awaitItem()).all {
|
||||
assertion()
|
||||
}
|
||||
|
||||
stateTurbine.ensureAllEventsConsumed()
|
||||
effectTurbine.ensureAllEventsConsumed()
|
||||
}
|
||||
|
||||
/**
|
||||
* A container class for the state and effect turbines of an MVI ViewModel.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue