package dev.kaizen.app

import dev.kaizen.app.ui.theme.themes.KaizenThemeId
import dev.kaizen.app.ui.theme.themes.ThemeRegistry
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test

class ThemeRegistryTest {

    @Test
    fun `registry contains all four themes`() {
        assertEquals(4, ThemeRegistry.all.size)
        val ids = ThemeRegistry.all.map { it.id }.toSet()
        assertTrue(ids.contains(KaizenThemeId.AMBER))
        assertTrue(ids.contains(KaizenThemeId.BLAU))
        assertTrue(ids.contains(KaizenThemeId.MONO))
        assertTrue(ids.contains(KaizenThemeId.AURORA))
    }

    @Test
    fun `forId returns correct theme`() {
        KaizenThemeId.entries.forEach { id ->
            val theme = ThemeRegistry.forId(id)
            assertEquals(id, theme.id)
        }
    }

    @Test
    fun `all themes have non-empty labels`() {
        ThemeRegistry.all.forEach { theme ->
            assertTrue("Theme ${theme.id} should have a label", theme.label.isNotBlank())
        }
    }

    @Test
    fun `all themes have distinct blob colors per scheme`() {
        ThemeRegistry.all.forEach { theme ->
            listOf(theme.dark, theme.light).forEach { scheme ->
                val blobs = setOf(scheme.blob1, scheme.blob2, scheme.blob3, scheme.blob4)
                assertTrue(
                    "Theme ${theme.id} should have at least 3 distinct blob colors",
                    blobs.size >= 3,
                )
            }
        }
    }

    @Test
    fun `KaizenThemeId fromString parses all ids`() {
        assertEquals(KaizenThemeId.AMBER, KaizenThemeId.fromString("amber"))
        assertEquals(KaizenThemeId.BLAU, KaizenThemeId.fromString("blue"))
        assertEquals(KaizenThemeId.MONO, KaizenThemeId.fromString("mono"))
        assertEquals(KaizenThemeId.AURORA, KaizenThemeId.fromString("aurora"))
    }

    @Test
    fun `KaizenThemeId fromString falls back to AMBER for unknown`() {
        assertEquals(KaizenThemeId.AMBER, KaizenThemeId.fromString("unknown"))
        assertEquals(KaizenThemeId.AMBER, KaizenThemeId.fromString(""))
    }
}
