24 lines
921 B
TypeScript
24 lines
921 B
TypeScript
import { gameConfig } from "@deadhead/content";
|
|
import { describe, expect, it } from "vitest";
|
|
import { MS_PER_HOUR, MS_PER_MINUTE, gameToReal, realToGame } from "../src/index";
|
|
|
|
const realStart = Date.parse(gameConfig.epoch.realStart);
|
|
const gameStart = Date.parse(gameConfig.epoch.ephemerisDate);
|
|
|
|
describe("game clock", () => {
|
|
it("maps the real epoch to the game epoch", () => {
|
|
expect(realToGame(realStart, gameConfig)).toBe(gameStart);
|
|
});
|
|
|
|
it("round-trips real → game → real", () => {
|
|
for (const real of [realStart, realStart + 12_345_678, Date.parse("2027-06-15T08:30:00Z")]) {
|
|
expect(gameToReal(realToGame(real, gameConfig), gameConfig)).toBe(real);
|
|
}
|
|
});
|
|
|
|
it("advances one game hour per real minute at compression 60", () => {
|
|
expect(gameConfig.timeCompression).toBe(60);
|
|
expect(realToGame(realStart + MS_PER_MINUTE, gameConfig)).toBe(gameStart + MS_PER_HOUR);
|
|
});
|
|
});
|