Skip to content

Instantly share code, notes, and snippets.

@LordRaydenMK
Created January 9, 2021 09:46
Show Gist options
  • Save LordRaydenMK/95080948abeca0f0a51cd16f88889834 to your computer and use it in GitHub Desktop.
Save LordRaydenMK/95080948abeca0f0a51cd16f88889834 to your computer and use it in GitHub Desktop.
Tests part 2
@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)
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(4) // (0) Loading, (1) Content, (2) Content (3) Content
.assertValueAt(3, Content(expected))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment