Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyguava committed Sep 24, 2023
1 parent dad41df commit 570fe47
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/commonTest/kotlin/app/cash/turbine/FlowTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,32 @@ class FlowTest {
}
}

@Test
fun delaysCanBeTested() = runTest {
val took = measureTime {
flow {
delay(5000)
emit("1")
delay(5000)
emit("2")
}.test {
expectNoEvents()

advanceTimeBy(5000)
expectNoEvents()

runCurrent()
assertEquals("1", awaitItem())

val exception = assertFailsWith<AssertionError> {
awaitItem()
}
assertEquals(exception.message, "No value produced in 3s")
}
}
assertTrue(took < 1.seconds, "$took > 1s")
}

@Test
fun timeoutsAreCaptured() = runTest {
flow<Nothing> {
Expand Down

0 comments on commit 570fe47

Please sign in to comment.