package com.tt.honeyDue.widget

import org.junit.Assert.assertEquals
import org.junit.Test

/**
 * Pure-JVM unit test for [WidgetFormatter.formatDueDateRelative].
 *
 * Mirrors the iOS `formatWidgetDate(_:)` helper in
 * `iosApp/HoneyDue/HoneyDue.swift` — both are responsible for rendering
 * a short human-friendly string from a `daysUntilDue` offset. Exact
 * wording must match so the two platforms ship indistinguishable widgets.
 */
class WidgetFormatterTest {

    @Test
    fun formatDueDateRelative_today() {
        assertEquals("Today", WidgetFormatter.formatDueDateRelative(daysUntilDue = 0))
    }

    @Test
    fun formatDueDateRelative_tomorrow_is_in_1_day() {
        // iOS formatter returns "in 1 day" for days==1 (it has no special
        // "Tomorrow" case — only "Today" and then "in N day(s)" / "N day(s) ago").
        assertEquals("in 1 day", WidgetFormatter.formatDueDateRelative(daysUntilDue = 1))
    }

    @Test
    fun formatDueDateRelative_in_3_days() {
        assertEquals("in 3 days", WidgetFormatter.formatDueDateRelative(daysUntilDue = 3))
    }

    @Test
    fun formatDueDateRelative_in_7_days() {
        assertEquals("in 7 days", WidgetFormatter.formatDueDateRelative(daysUntilDue = 7))
    }

    @Test
    fun formatDueDateRelative_one_day_ago() {
        assertEquals("1 day ago", WidgetFormatter.formatDueDateRelative(daysUntilDue = -1))
    }

    @Test
    fun formatDueDateRelative_five_days_ago() {
        assertEquals("5 days ago", WidgetFormatter.formatDueDateRelative(daysUntilDue = -5))
    }

    @Test
    fun taskCountLabel_singular_plural() {
        // iOS FreeWidgetView: "task waiting" / "tasks waiting"
        assertEquals("task waiting", WidgetFormatter.taskCountLabel(1))
        assertEquals("tasks waiting", WidgetFormatter.taskCountLabel(0))
        assertEquals("tasks waiting", WidgetFormatter.taskCountLabel(5))
    }

    @Test
    fun compactTaskCountLabel_singular_plural() {
        // iOS Small/Medium widgets: short "task"/"tasks" under the count.
        assertEquals("task", WidgetFormatter.compactTaskCountLabel(1))
        assertEquals("tasks", WidgetFormatter.compactTaskCountLabel(0))
        assertEquals("tasks", WidgetFormatter.compactTaskCountLabel(3))
    }
}
