package com.swoosh.microblog.ui.theme

import org.junit.Assert.*
import org.junit.Test

class ThemeModeTest {

    @Test
    fun `ThemeMode has exactly 3 values`() {
        assertEquals(3, ThemeMode.values().size)
    }

    @Test
    fun `ThemeMode values are SYSTEM, LIGHT, DARK`() {
        val values = ThemeMode.values().toList()
        assertEquals(ThemeMode.SYSTEM, values[0])
        assertEquals(ThemeMode.LIGHT, values[1])
        assertEquals(ThemeMode.DARK, values[2])
    }

    @Test
    fun `ThemeMode valueOf works for all values`() {
        assertEquals(ThemeMode.SYSTEM, ThemeMode.valueOf("SYSTEM"))
        assertEquals(ThemeMode.LIGHT, ThemeMode.valueOf("LIGHT"))
        assertEquals(ThemeMode.DARK, ThemeMode.valueOf("DARK"))
    }

    @Test(expected = IllegalArgumentException::class)
    fun `ThemeMode valueOf throws for invalid value`() {
        ThemeMode.valueOf("INVALID")
    }

    // --- Cycling logic ---

    @Test
    fun `next from SYSTEM returns LIGHT`() {
        assertEquals(ThemeMode.LIGHT, ThemeMode.SYSTEM.next())
    }

    @Test
    fun `next from LIGHT returns DARK`() {
        assertEquals(ThemeMode.DARK, ThemeMode.LIGHT.next())
    }

    @Test
    fun `next from DARK returns SYSTEM`() {
        assertEquals(ThemeMode.SYSTEM, ThemeMode.DARK.next())
    }

    @Test
    fun `cycling through all modes returns to start`() {
        val start = ThemeMode.SYSTEM
        val afterFirst = start.next()
        val afterSecond = afterFirst.next()
        val afterThird = afterSecond.next()
        assertEquals(start, afterThird)
    }

    @Test
    fun `full cycle from LIGHT returns to LIGHT`() {
        val start = ThemeMode.LIGHT
        assertEquals(start, start.next().next().next())
    }

    @Test
    fun `full cycle from DARK returns to DARK`() {
        val start = ThemeMode.DARK
        assertEquals(start, start.next().next().next())
    }
}
