import { content } from "@deadhead/content"; import { describe, expect, it } from "vitest"; import { routeDistance } from "../src/index"; const earth = content.location("earth")!; const moon = content.location("moon")!; const mars = content.location("mars")!; const start = Date.parse("2100-01-01T00:00:00Z"); const MS_PER_DAY = 86_400_000; /** Game times sampled every ~30 days across two years. */ const monthly = Array.from({ length: 25 }, (_, i) => start + i * 30 * MS_PER_DAY); describe("route distance", () => { it("keeps Earth→Moon under 1 million km at any time", () => { for (const t of monthly) { expect(routeDistance(earth, moon, t)).toBeLessThan(1); } }); it("varies Earth→Mars by at least 200 million km over two years", () => { const distances = monthly.map((t) => routeDistance(earth, mars, t)); expect(Math.max(...distances) - Math.min(...distances)).toBeGreaterThanOrEqual(200); }); it("is symmetric", () => { for (const a of content.locations) { for (const b of content.locations) { expect(routeDistance(a, b, start)).toBe(routeDistance(b, a, start)); } } }); });