Repository: android/compose-samples
File: Jetcaster/core/src/test/kotlin/com/example/jetcaster/core/player/MockEpisodePlayerTest.kt (Kotlin)

Code before:
            duration = Duration.ofSeconds(60)
        ),
        PlayerEpisode(
            uri = "uri3",
            duration = Duration.ofSeconds(60)
        ),
    )

    @Test
    fun playerAutoPlaysNextEpisode() = runTest(testDispatcher) {
        val duration = Duration.ofSeconds(60)
        val currEpisode = PlayerEpisode(
            uri = "currentEpisode",
            duration = duration
        )
        mockEpisodePlayer.currentEpisode = currEpisode
        testEpisodes.forEach { mockEpisodePlayer.addToQueue(it) }

        mockEpisodePlayer.play()
        advanceTimeBy(duration.toMillis() + 1)

        assertEquals(testEpisodes.first(), mockEpisodePlayer.currentEpisode)
    }

    @Test
    fun whenNextQueueEmpty_doesNothing() {
        val episode = testEpisodes[0]
        mockEpisodePlayer.currentEpisode = episode
        mockEpisodePlayer.play()

        mockEpisodePlayer.next()

        assertEquals(episode, mockEpisodePlayer.currentEpisode)
    }

    @Test
    fun whenAddToQueue_queueNotEmpty() = runTest(testDispatcher) {
        testEpisodes.forEach { mockEpisodePlayer.addToQueue(it) }

        advanceUntilIdle()

        val queue = mockEpisodePlayer.playerState.value.queue
        assertEquals(testEpisodes.size, queue.size)
        testEpisodes.forEachIndexed { index, playerEpisode ->
            assertEquals(playerEpisode, queue[index])
        }
    }

    @Test
    fun whenNextQueueNotEmpty_removeFromQueue() = runTest(testDispatcher) {
        mockEpisodePlayer.currentEpisode = PlayerEpisode(

Review comment (suggestion):
Minor nit about naming: this combines the "given" and "when" of the test, which reads a little strange. I suggest separating them with another underscore, e.g. `whenNext_queueIsEmpty_doesNothing()`.

Same for other tests in this file.

Code after:
            duration = Duration.ofSeconds(60)
        ),
        PlayerEpisode(
            uri = "uri3",
            duration = Duration.ofSeconds(60)
        ),
    )

    @Test
    fun whenPlayDone_playerAutoPlaysNextEpisode() = runTest(testDispatcher) {
        val duration = Duration.ofSeconds(60)
        val currEpisode = PlayerEpisode(
            uri = "currentEpisode",
            duration = duration
        )
        mockEpisodePlayer.currentEpisode = currEpisode
        testEpisodes.forEach { mockEpisodePlayer.addToQueue(it) }

        mockEpisodePlayer.play()
        advanceTimeBy(duration.toMillis() + 1)

        assertEquals(testEpisodes.first(), mockEpisodePlayer.currentEpisode)
    }

    @Test
    fun whenNext_queueIsEmpty_doesNothing() {
        val episode = testEpisodes[0]
        mockEpisodePlayer.currentEpisode = episode
        mockEpisodePlayer.play()

        mockEpisodePlayer.next()

        assertEquals(episode, mockEpisodePlayer.currentEpisode)
    }

    @Test
    fun whenAddToQueue_queueIsNotEmpty() = runTest(testDispatcher) {
        testEpisodes.forEach { mockEpisodePlayer.addToQueue(it) }

        advanceUntilIdle()

        val queue = mockEpisodePlayer.playerState.value.queue
        assertEquals(testEpisodes.size, queue.size)
        testEpisodes.forEachIndexed { index, playerEpisode ->
            assertEquals(playerEpisode, queue[index])
        }
    }

    @Test
    fun whenNext_queueIsNotEmpty_removeFromQueue() = runTest(testDispatcher) {
        mockEpisodePlayer.currentEpisode = PlayerEpisode(