Created
January 9, 2021 09:45
-
-
Save LordRaydenMK/5c0f5d0cf061e993ea48adbb052429e6 to your computer and use it in GitHub Desktop.
Tests part v1
This file contains 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 `execute - first call succeeds, one failed call to #2 - one full item, one item with default value`() { | |
val items = listOf("Item 1" to "https://item1.jpg", "Item 2" to "invalid url") | |
val service = successService(items) // Fake implementation of a retrofit service, always returns success | |
val viewModel = ViewModel(service) | |
val expected = listOf( | |
ViewEntity("Item 1", "https://item1.jpg".toHttpUrl()), | |
ViewEntity("Item 2", null) | |
) | |
viewModel.state | |
.test() | |
.also { viewModel.execute() } | |
.awaitCount(2) // (0) Loading, (1) Content | |
.assertValueAt(1, Content(expected)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment