mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-11 09:23:50 +01:00
adding test helper for asserting states whilst combining previous updates
This commit is contained in:
parent
c15e908a15
commit
4225f62120
@ -55,6 +55,17 @@ class ViewModelTest<S, VE>(
|
||||
return this
|
||||
}
|
||||
|
||||
fun assertStatesWithPrevious(initial: S, vararg expected: S.() -> S): ViewModelTest<S, VE> {
|
||||
val reducedExpectedStates = expected.fold(mutableListOf(initial)) { acc, curr ->
|
||||
val next = curr.invoke(acc.last())
|
||||
acc.add(next)
|
||||
acc
|
||||
}
|
||||
|
||||
states.assertValues(reducedExpectedStates)
|
||||
return this
|
||||
}
|
||||
|
||||
fun assertStates(expected: List<S>): ViewModelTest<S, VE> {
|
||||
states.assertValues(expected)
|
||||
return this
|
||||
|
Loading…
Reference in New Issue
Block a user