package pl.firmatpp.kierowca.sync

import java.time.LocalDate
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import pl.firmatpp.kierowca.data.model.DriverRouteDto

class NewRouteNotificationFormatterTest {
    @Test
    fun formatsHumanRouteDates() {
        val today = LocalDate.of(2026, 7, 2)

        assertEquals("Nowy kurs: dzisiaj", NewRouteNotificationFormatter.title("2026-07-02", today))
        assertEquals("Nowy kurs: jutro", NewRouteNotificationFormatter.title("2026-07-03", today))
        assertEquals("Nowy kurs: w sobotę", NewRouteNotificationFormatter.title("2026-07-04", today))
        assertEquals("Nowy kurs: 12 lipca", NewRouteNotificationFormatter.title("2026-07-12", today))
    }

    @Test
    fun formatsCollapsedAndExpandedRouteText() {
        val route = DriverRouteDto(
            id = "42",
            routeDate = "2026-07-03",
            startsAt = "09:15",
            originName = "TPP Baza Krakow",
            destinationName = "Instalacja Odpadowa Slask",
            contractorName = "TPP Baza Krakow",
            contractName = "Odpady przemyslowe",
            contractCode = "TPP-ODP-24",
            relationLabel = "TPP Baza Krakow -> Instalacja Odpadowa Slask",
            status = "ZAPLANOWANA",
            distanceKm = 91.4,
            notes = null,
            truck = null,
        )

        assertEquals(
            "TPP Baza Krakow → Instalacja Odpadowa Slask · Odpady przemyslowe",
            NewRouteNotificationFormatter.collapsedText(route),
        )
        assertTrue(NewRouteNotificationFormatter.expandedText(route).contains("Skąd: TPP Baza Krakow"))
        assertTrue(NewRouteNotificationFormatter.expandedText(route).contains("Dokąd: Instalacja Odpadowa Slask"))
        assertTrue(NewRouteNotificationFormatter.expandedText(route).contains("Kontrakt: Odpady przemyslowe"))
    }
}
