Created
October 9, 2019 08:57
-
-
Save manuelvicnt/e66e5ca0b60b4afd80f21988d6716c68 to your computer and use it in GitHub Desktop.
Plaid - ShowViewModelTest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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