mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-16 19:28:54 +03:00
adding test helper for asserting states whilst combining previous updates
This commit is contained in:
parent
c15e908a15
commit
4225f62120
1 changed files with 11 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue