Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Plaid - ShowViewModelTest
@Test
fun loadShot_emitsTwoUiModels() {
// When the ViewModel has started
val viewModel = ... // Creates viewModel
// Then the fast result has been emitted
val fastResult = viewModel.shotUiModel.getOrAwaitValue()
// THIS FAILS!!! The slow result has already been emitted because the coroutine
// was executed immediately and shotUiModel LiveData contains the slow result
assertTrue(fastResult.formattedDescription.isEmpty())
// And then, the slow result has been emitted
val slowResult = viewModel.shotUiModel.getOrAwaitValue()
assertTrue(slowResult.formattedDescription.isNotEmpty())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.