package com.tt.honeyDue.ui.theme

import androidx.compose.ui.unit.sp
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue

/**
 * P1 Stream A — Typography scale sanity tests.
 *
 * iOS uses the rounded design system font with dynamic-type defaults.
 * We don't attempt to match the iOS scale pixel-perfectly (it adapts to
 * the device); we just lock in the semantic sizes we chose for Android
 * so they cannot be accidentally regressed.
 */
class TypographyTest {

    @Test
    fun typographyInstanceIsConfigured() {
        assertNotNull(AppTypography, "AppTypography must be defined")
    }

    @Test
    fun bodyScaleMatchesIosDynamicTypeDefaults() {
        // iOS "body" text style defaults to 17pt.
        assertEquals(17.sp, AppTypography.bodyLarge.fontSize, "body=17sp (iOS body)")
        assertEquals(15.sp, AppTypography.bodyMedium.fontSize, "callout=15sp")
        assertEquals(13.sp, AppTypography.bodySmall.fontSize, "footnote=13sp")
    }

    @Test
    fun headlineScaleMatchesIosDynamicTypeDefaults() {
        // iOS "largeTitle" defaults to 34pt but we use 32 for Android consistency.
        // "title1" = 28pt, "title2" = 22pt, "title3" = 20pt.
        assertEquals(32.sp, AppTypography.headlineLarge.fontSize)
        assertEquals(28.sp, AppTypography.headlineMedium.fontSize)
        assertEquals(24.sp, AppTypography.headlineSmall.fontSize)
    }

    @Test
    fun titleAndLabelScaleAreDefined() {
        assertEquals(22.sp, AppTypography.titleLarge.fontSize)
        assertEquals(18.sp, AppTypography.titleMedium.fontSize)
        assertEquals(16.sp, AppTypography.titleSmall.fontSize)

        assertEquals(14.sp, AppTypography.labelLarge.fontSize)
        assertEquals(12.sp, AppTypography.labelMedium.fontSize)
        // iOS "caption2" default = 11pt.
        assertEquals(11.sp, AppTypography.labelSmall.fontSize)
    }

    @Test
    fun allStylesHavePositiveLineHeight() {
        val styles = listOf(
            AppTypography.displayLarge, AppTypography.displayMedium, AppTypography.displaySmall,
            AppTypography.headlineLarge, AppTypography.headlineMedium, AppTypography.headlineSmall,
            AppTypography.titleLarge, AppTypography.titleMedium, AppTypography.titleSmall,
            AppTypography.bodyLarge, AppTypography.bodyMedium, AppTypography.bodySmall,
            AppTypography.labelLarge, AppTypography.labelMedium, AppTypography.labelSmall,
        )
        styles.forEach { style ->
            assertTrue(
                style.lineHeight.value > 0f,
                "lineHeight must be positive for every style"
            )
        }
    }
}
