package dev.kaizen.app

import dev.kaizen.app.ui.effect.KaizenShadows
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test

class ShadowStackTest {

    @Test
    fun `level0 has no layers`() {
        assertTrue(KaizenShadows.level0.layers.isEmpty())
    }

    @Test
    fun `level1 has 2 layers`() {
        assertEquals(2, KaizenShadows.level1.layers.size)
    }

    @Test
    fun `level2 has 3 layers`() {
        assertEquals(3, KaizenShadows.level2.layers.size)
    }

    @Test
    fun `level3 has 4 layers`() {
        assertEquals(4, KaizenShadows.level3.layers.size)
    }

    @Test
    fun `level4 has 4 layers`() {
        assertEquals(4, KaizenShadows.level4.layers.size)
    }

    @Test
    fun `all alphas are in valid range`() {
        listOf(
            KaizenShadows.level1,
            KaizenShadows.level2,
            KaizenShadows.level3,
            KaizenShadows.level4,
        ).forEach { stack ->
            stack.layers.forEach { layer ->
                assertTrue("Alpha ${layer.alpha} should be in 0..1", layer.alpha in 0f..1f)
            }
        }
    }

    @Test
    fun `blur increases with each layer in level3`() {
        val blurs = KaizenShadows.level3.layers.map { it.blur }
        for (i in 1 until blurs.size) {
            assertTrue(
                "Blur should increase: ${blurs[i - 1]} < ${blurs[i]}",
                blurs[i] > blurs[i - 1],
            )
        }
    }

    @Test
    fun `alpha decreases with each layer in level3`() {
        val alphas = KaizenShadows.level3.layers.map { it.alpha }
        for (i in 1 until alphas.size) {
            assertTrue(
                "Alpha should decrease: ${alphas[i - 1]} > ${alphas[i]}",
                alphas[i] < alphas[i - 1],
            )
        }
    }
}
