29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { content } from "@deadhead/content";
|
|
import { describe, expect, it } from "vitest";
|
|
import { routeDistance, travelTimeGameHours } from "../src/index";
|
|
|
|
const courier = content.shipModel("courier")!;
|
|
const freighter = content.shipModel("freighter")!;
|
|
|
|
describe("travel time", () => {
|
|
it("matches a hand calculation", () => {
|
|
// 150M km at 2M km/h = 75 h cruise, plus 4 h overhead.
|
|
expect(travelTimeGameHours(freighter, 150)).toBe(79);
|
|
});
|
|
|
|
it("gets a faster ship there sooner on the same route", () => {
|
|
for (const distance of [0.384, 50, 400]) {
|
|
expect(travelTimeGameHours(courier, distance)).toBeLessThan(
|
|
travelTimeGameHours(freighter, distance),
|
|
);
|
|
}
|
|
});
|
|
|
|
it("is mostly overhead for a Courier on Earth→Moon", () => {
|
|
const t = Date.parse("2100-01-01T00:00:00Z");
|
|
const distance = routeDistance(content.location("earth")!, content.location("moon")!, t);
|
|
const total = travelTimeGameHours(courier, distance);
|
|
expect(courier.overheadGameHours).toBeGreaterThan(total / 2);
|
|
});
|
|
});
|