"""nav_sparkline renders a self-contained inline SVG polyline from a NAV series (no JS, no external libs)."""
from __future__ import annotations

from fxhnt.adapters.web.charts import nav_sparkline


def test_sparkline_is_svg_with_points() -> None:
    svg = nav_sparkline([1.0, 1.01, 1.005, 1.02], width=100, height=20)
    assert svg.startswith("<svg") and svg.rstrip().endswith("</svg>")
    assert "<polyline" in svg and "points=" in svg


def test_sparkline_empty_series_is_safe() -> None:
    svg = nav_sparkline([], width=100, height=20)
    assert svg.startswith("<svg") and "polyline" not in svg


def test_sparkline_flat_series_does_not_divide_by_zero() -> None:
    svg = nav_sparkline([1.0, 1.0, 1.0], width=100, height=20)
    assert "<polyline" in svg            # flat line, no exception
