import { content, type ShipModel } from "@deadhead/content"; import { describe, expect, it } from "vitest"; import { checkRoute } from "../src/index"; const earth = content.location("earth")!; const moon = content.location("moon")!; const mars = content.location("mars")!; const ceres = content.location("ceres-station")!; const jupiter = content.location("jupiter-cloud-platform")!; const courier = content.shipModel("courier")!; const freighter = content.shipModel("freighter")!; const bulkHauler = content.shipModel("bulk-hauler")!; /** Test-only ship that cannot land on atmospheric worlds. */ const vacuumShip: ShipModel = { ...courier, id: "test-vacuum", landingClass: "vacuum" }; // The map is fixed (decision 0.5.93), so any time gives the same answer. const outOfRange = { ok: false, reason: "out-of-range" }; // Origins are named in every test (decision 0.5.77: range is per leg, from its origin). describe("route eligibility", () => { it("lets a Courier fly Earth→Moon and Moon→Earth", () => { expect(checkRoute(courier, earth, moon)).toEqual({ ok: true }); expect(checkRoute(courier, moon, earth)).toEqual({ ok: true }); }); it("keeps a Courier from Earth out of range of Mars, Ceres and Jupiter", () => { for (const to of [mars, ceres, jupiter]) { expect(checkRoute(courier, earth, to)).toEqual(outOfRange); } }); it("rejects a vacuum-only ship at Earth because it cannot land", () => { expect(checkRoute(vacuumShip, moon, earth)).toEqual({ ok: false, reason: "cannot-land", }); expect(checkRoute(vacuumShip, earth, moon)).toEqual({ ok: true }); }); it("lets a Freighter from Earth reach Mars and Ceres (CR-015 §4)", () => { expect(checkRoute(freighter, earth, mars)).toEqual({ ok: true }); expect(checkRoute(freighter, earth, ceres)).toEqual({ ok: true }); }); it("lets only the Bulk Hauler reach Jupiter from Earth", () => { expect(checkRoute(bulkHauler, earth, jupiter)).toEqual({ ok: true }); expect(checkRoute(freighter, earth, jupiter)).toEqual(outOfRange); expect(checkRoute(courier, earth, jupiter)).toEqual(outOfRange); }); });