defmodule Microwaveprop.FormatTest do
  use ExUnit.Case, async: true

  alias Microwaveprop.Format

  describe "distance_km/1" do
    test "returns em-dash for nil" do
      assert Format.distance_km(nil) == "—"
    end

    test "formats large distances as whole numbers, miles first" do
      assert Format.distance_km(235) == "146 mi (235 km)"
      assert Format.distance_km(100.0) == "62 mi (100 km)"
    end

    test "formats short distances with one decimal" do
      assert Format.distance_km(1.5) == "0.9 mi (1.5 km)"
      assert Format.distance_km(9.6) == "6.0 mi (9.6 km)"
    end

    test "accepts Decimal input" do
      assert Format.distance_km(Decimal.new("235")) == "146 mi (235 km)"
    end
  end
end
