Skip to content

Instantly share code, notes, and snippets.

@micHar
Last active June 22, 2022 08:51
Show Gist options
  • Save micHar/0d5553ea25105ac6c8e34eeec03587ba to your computer and use it in GitHub Desktop.
Save micHar/0d5553ea25105ac6c8e34eeec03587ba to your computer and use it in GitHub Desktop.
@Test
fun `should change state to Playing after play() called`() = runTest(UnconfinedTestDispatcher()) {
val soundPlayer = mockk<SoundPlayer>()
coJustRun { soundPlayer.playSound() }
val sut = MediaPlayer(this, soundPlayer)
sut.playerState.test {
awaitItem() shouldBe PlayerState.Stopped
sut.play()
awaitItem() shouldBe PlayerState.Playing
cancelAndIgnoreRemainingEvents()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment