Skip to content

Instantly share code, notes, and snippets.

@dladukedev
Created July 25, 2023 15:15
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Mockup showing the issue with combine where Turbine misses elements
@Test
fun `this test fails`() = runTest {
val number = (0..2).asFlow()
val intro = listOf("Hello").asFlow()
val combined = combine(intro, number) { first, second ->
"$first $second"
}
combined.test {
assertEquals("Hello 0", awaitItem())
assertEquals("Hello 1", awaitItem())
assertEquals("Hello 2", awaitItem())
awaitComplete()
}
}
@Test
fun `this test succeeds`() = runTest {
val number = (0..2).asFlow().onEach { delay(1) }
val intro = listOf("Hello").asFlow()
val combined = combine(intro, number) { first, second ->
"$first $second"
}
combined.test {
assertEquals("Hello 0", awaitItem())
assertEquals("Hello 1", awaitItem())
assertEquals("Hello 2", awaitItem())
awaitComplete()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment