package com.jsjdesigns.poker

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

class CashGameSessionTest {

    @Test
    fun `blank player name has an honest second-person fallback`() {
        assertEquals("You", cashGameConfig("   ").playerName)
        assertFalse("coach must be opt-in", cashGameConfig("Jay").coachEnabled)
    }

    @Test
    fun `coach preference crosses the session boundary explicitly`() {
        assertTrue(cashGameConfig("Jay", coachEnabled = true).coachEnabled)
    }

    @Test
    fun `player name is normalised once at the session boundary`() {
        assertEquals("Jay Smith", cashGameConfig("  Jay   Smith  ").playerName)
        assertEquals(
            MAX_PLAYER_NAME_LENGTH,
            cashGameConfig("A name much too long for a phone table").playerName.length,
        )
    }

    @Test
    fun `automatic top ups categorically exclude the human seat`() {
        val topUps = automaticTopUpSeatIndices(
            stacks = listOf(0, 0, 1, 2, 200),
            heroSeat = 0,
            bigBlind = 2,
        )

        assertEquals(listOf(1, 2), topUps)
        assertFalse(HERO_SEAT in topUps)
    }

    @Test
    fun `continuation copy promises the exact stack the reload produces`() {
        assertEquals(
            "Reload to 200 & deal",
            continuationButtonLabel(
                nextHandRequested = false,
                rebuyRequired = true,
                buyIn = 200,
            ),
        )
        assertEquals("Next hand", continuationButtonLabel(false, false, 200))
        assertEquals("Dealing…", continuationButtonLabel(true, true, 200))
        assertTrue(continuationButtonLabel(false, true, 200).contains("200"))
    }
}
