package com.fabledsword.minstrel.player.output

import org.junit.jupiter.api.Test
import kotlin.test.assertEquals

class IdleRevertDecisionTest {

    @Test
    fun `engaged and paused and not armed arms the timer`() {
        assertEquals(
            IdleRevertAction.ARM,
            idleRevertAction(upnpEngaged = true, isPlaying = false, armed = false),
        )
    }

    @Test
    fun `engaged and paused and already armed is ignored`() {
        assertEquals(
            IdleRevertAction.IGNORE,
            idleRevertAction(upnpEngaged = true, isPlaying = false, armed = true),
        )
    }

    @Test
    fun `resuming playback cancels an armed timer`() {
        assertEquals(
            IdleRevertAction.CANCEL,
            idleRevertAction(upnpEngaged = true, isPlaying = true, armed = true),
        )
    }

    @Test
    fun `playing with no timer armed is ignored`() {
        assertEquals(
            IdleRevertAction.IGNORE,
            idleRevertAction(upnpEngaged = true, isPlaying = true, armed = false),
        )
    }

    @Test
    fun `disengaging UPnP cancels an armed timer`() {
        assertEquals(
            IdleRevertAction.CANCEL,
            idleRevertAction(upnpEngaged = false, isPlaying = false, armed = true),
        )
    }

    @Test
    fun `disengaged with no timer armed is ignored`() {
        assertEquals(
            IdleRevertAction.IGNORE,
            idleRevertAction(upnpEngaged = false, isPlaying = true, armed = false),
        )
    }
}
