defmodule Microwaveprop.Rover.DriveTimeTest do
  use ExUnit.Case, async: true

  alias Microwaveprop.Rover.DriveTime

  describe "haversine_km/2" do
    test "DFW area to Austin ≈ 305 km" do
      assert_in_delta DriveTime.haversine_km({32.9, -97.0}, {30.27, -97.74}), 305.0, 5.0
    end
  end

  describe "drive_min/1" do
    test "200 km at 65 km/h ≈ 184.6 min" do
      assert_in_delta DriveTime.drive_min(200.0), 184.6, 0.5
    end
  end

  describe "bearing_compass/2" do
    test "due north" do
      assert DriveTime.bearing_compass({33.0, -96.0}, {34.0, -96.0}) == "N"
    end

    test "due east" do
      assert DriveTime.bearing_compass({33.0, -96.0}, {33.0, -95.0}) == "E"
    end

    test "north-east" do
      assert DriveTime.bearing_compass({33.0, -96.0}, {33.5, -95.5}) == "NE"
    end
  end
end
