address review: signal now playing with an event flow, not an int

This commit is contained in:
austinried
2026-10-04 00:30:07 +00:00
parent fd3b1ce298
commit b3cad97869
5 changed files with 57 additions and 15 deletions
@@ -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() })
}
}