mirror of
https://github.com/austinried/subtracks.git
synced 2026-11-10 23:21:59 +01:00
address review: signal now playing with an event flow, not an int
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.subtracks.ui
|
||||
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class NowPlayingLauncherTest {
|
||||
@Test
|
||||
fun aRequestMadeBeforeCollectionIsDelivered() =
|
||||
runTest {
|
||||
val launcher = NowPlayingLauncher()
|
||||
launcher.request()
|
||||
assertEquals(Unit, launcher.openNowPlaying.first())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun repeatedRequestsCollapseToTheLatest() =
|
||||
runTest {
|
||||
val launcher = NowPlayingLauncher()
|
||||
repeat(3) { launcher.request() }
|
||||
assertEquals(Unit, launcher.openNowPlaying.first())
|
||||
assertNull(withTimeoutOrNull(100) { launcher.openNowPlaying.first() })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user