import { content } from "@deadhead/content"; import { describe, expect, it } from "vitest"; import { routeDistance, travelTimeGameHours } from "../src/index"; const config = content.config; const courier = content.shipModel("courier")!; const freighter = content.shipModel("freighter")!; const loaner = content.shipModel("company-courier")!; const earthMoon = () => routeDistance(content.location("earth")!, content.location("moon")!); describe("travel time", () => { it("matches a hand calculation, including handling time", () => { // 150M km at 2M km/h = 75 h cruise, plus 4 h overhead, plus 50 t × 0.02 h/t = 1 h handling. expect(travelTimeGameHours(freighter, 150, 50, config)).toBe(80); }); it("gets a faster ship there sooner on the same route", () => { for (const distance of [0.384, 50, 400]) { expect(travelTimeGameHours(courier, distance, 10, config)).toBeLessThan( travelTimeGameHours(freighter, distance, 10, config), ); } }); it("is mostly overhead for a Courier on Earth→Moon", () => { const total = travelTimeGameHours(courier, earthMoon(), 10, config); expect(courier.overheadGameHours).toBeGreaterThan(total / 2); }); }); describe("handling time (decision 0.5.31)", () => { it("makes a heavier contract take longer than a lighter one on the same route and ship", () => { const distance = earthMoon(); expect(travelTimeGameHours(courier, distance, 20, config)).toBeGreaterThan( travelTimeGameHours(courier, distance, 5, config), ); }); it("gives a reposition (zero mass) the old formula's time", () => { const distance = 150; const oldFormula = (distance * 1e6) / freighter.cruiseSpeedKmPerGameHour + freighter.overheadGameHours; expect(travelTimeGameHours(freighter, distance, 0, config)).toBe(oldFormula); }); it("keeps a full Company Courier tutorial run Earth→Moon under 1 game hour (1 real minute)", () => { const hours = travelTimeGameHours(loaner, earthMoon(), config.tutorialMassTonnes.full, config); expect(hours).toBeLessThan(1); expect(config.timeCompression).toBe(60); }); });