Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Created October 9, 2019 08:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manuelvicnt/e66e5ca0b60b4afd80f21988d6716c68 to your computer and use it in GitHub Desktop.
Save manuelvicnt/e66e5ca0b60b4afd80f21988d6716c68 to your computer and use it in GitHub Desktop.
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