package solutions.tretter.mindmachine

import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test

class SetupScreenUiLogicTest {
    @Test
    fun flash_interval_label_uses_seconds_text_source() {
        assertEquals("Flash interval: 0.17 s", setupScreenFlashIntervalLabel(167))
        assertEquals("Flash interval: 2.00 s", setupScreenFlashIntervalLabel(2000))
    }

    @Test
    fun setup_screen_layout_uses_scrollable_container() {
        assertTrue(setupScreenUsesScrollableContainer())
    }

    @Test
    fun program_selection_numbers_use_at_most_two_decimals() {
        assertEquals("12", formatMaxTwoDecimals(12f))
        assertEquals("4.5", formatMaxTwoDecimals(4.5f))
        assertEquals("4.57", formatMaxTwoDecimals(4.567f))
    }

    @Test
    fun setup_screen_unsaved_changes_true_when_timeline_dirty() {
        assertTrue(
            setupScreenHasUnsavedChanges(
                hasUnsavedTimelineChanges = true,
                editedProgramName = "Deep Release",
                savedProgramName = "Deep Release",
            )
        )
    }

    @Test
    fun setup_screen_unsaved_changes_true_when_name_changed() {
        assertTrue(
            setupScreenHasUnsavedChanges(
                hasUnsavedTimelineChanges = false,
                editedProgramName = "Deep Release v2",
                savedProgramName = "Deep Release",
            )
        )
    }

    @Test
    fun setup_screen_unsaved_changes_false_when_name_and_timeline_match() {
        assertFalse(
            setupScreenHasUnsavedChanges(
                hasUnsavedTimelineChanges = false,
                editedProgramName = "Deep Release",
                savedProgramName = "Deep Release",
            )
        )
    }
}
