import { content } from "@deadhead/content"; import { describe, expect, it } from "vitest"; import { fuelCost, routeDistance } from "../src/index"; const courier = content.shipModel("courier")!; const earth = content.location("earth")!; const moon = content.location("moon")!; describe("fuel cost", () => { it("costs more Earth→Moon than Moon→Earth for the same ship", () => { const t = Date.parse("2100-01-01T00:00:00Z"); const distance = routeDistance(earth, moon, t); expect(fuelCost(courier, earth, distance)).toBeGreaterThan(fuelCost(courier, moon, distance)); }); it("scales linearly with distance", () => { expect(fuelCost(courier, earth, 2)).toBe(2 * fuelCost(courier, earth, 1)); expect(fuelCost(courier, earth, 10)).toBe(10 * fuelCost(courier, earth, 1)); }); it("matches a hand calculation", () => { // 0.5M km × 200 credits/M km × Earth multiplier 2.1. expect(fuelCost(courier, earth, 0.5)).toBeCloseTo(210); }); });