"""Tests for the shared duration formatter."""

from __future__ import annotations

from clients.terminal.tui.duration import format_duration


def test_format_duration_none() -> None:
    assert format_duration(None) == "—"


def test_format_duration_seconds() -> None:
    assert format_duration(0) == "0s"
    assert format_duration(16.4) == "16s"
    assert format_duration(59.6) == "1m 0s"  # rounds to 60 -> 1m 0s


def test_format_duration_minutes() -> None:
    assert format_duration(136) == "2m 16s"
    assert format_duration(599) == "9m 59s"


def test_format_duration_hours() -> None:
    assert format_duration(3725) == "1h 2m"
    assert format_duration(3600) == "1h 0m"