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("gives the same distance at every time (decision 0.5.93)", () => { const first = routeDistance(earth, mars, monthly[0]!); for (const t of monthly) expect(routeDistance(earth, mars, t)).toBe(first); }); 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)); } } }); });