Created
July 25, 2023 15:15
-
-
Save dladukedev/f1563dc712fcf41ae6a4914a52ba78bf to your computer and use it in GitHub Desktop.
Mockup showing the issue with combine where Turbine misses elements
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 `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