package space.nstart.pcp.pcp_request_service.utils

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.time.LocalDateTime

class UtcDateTimesTest {

    @Test
    fun `parses utc instant with z suffix`() {
        assertEquals(
            LocalDateTime.of(2026, 6, 17, 6, 28, 27, 334_000_000),
            UtcDateTimes.parse("2026-06-17T06:28:27.334Z")
        )
    }

    @Test
    fun `normalizes offset date time to utc naive local date time`() {
        assertEquals(
            LocalDateTime.of(2026, 6, 17, 6, 28, 27),
            UtcDateTimes.parse("2026-06-17T09:28:27+03:00")
        )
    }

    @Test
    fun `keeps legacy naive date time as utc naive`() {
        assertEquals(
            LocalDateTime.of(2026, 6, 17, 6, 28, 0),
            UtcDateTimes.parse("2026-06-17T06:28")
        )
    }

    @Test
    fun `formats utc naive date time with z suffix`() {
        assertEquals(
            "2026-06-17T06:28:27.334Z",
            UtcDateTimes.format(LocalDateTime.of(2026, 6, 17, 6, 28, 27, 334_000_000))
        )
    }
}
