package fuck.andes.config

import org.junit.Assert.assertEquals
import org.junit.Test

class PowerAssistantTargetTest {
    @Test
    fun `valid persisted values select matching target`() {
        assertEquals(
            PowerAssistantTarget.OEM,
            PowerAssistantTarget.resolve("oem", legacyPowerKeyTakeover = true),
        )
        assertEquals(
            PowerAssistantTarget.ETA,
            PowerAssistantTarget.resolve("eta", legacyPowerKeyTakeover = false),
        )
    }

    @Test
    fun `missing persisted value preserves legacy power key takeover`() {
        assertEquals(
            PowerAssistantTarget.ETA,
            PowerAssistantTarget.resolve(null, legacyPowerKeyTakeover = true),
        )
    }

    @Test
    fun `missing persisted value preserves legacy OEM behavior`() {
        assertEquals(
            PowerAssistantTarget.OEM,
            PowerAssistantTarget.resolve(null, legacyPowerKeyTakeover = false),
        )
    }

    @Test
    fun `unknown persisted value falls back to legacy setting`() {
        assertEquals(
            PowerAssistantTarget.ETA,
            PowerAssistantTarget.resolve("unknown", legacyPowerKeyTakeover = true),
        )
        assertEquals(
            PowerAssistantTarget.OEM,
            PowerAssistantTarget.resolve("unknown", legacyPowerKeyTakeover = false),
        )
    }
}
