deadhead-space-freight-tycoon/packages/engine/test/ported/time.test.ts

18 lines
770 B
TypeScript

// Ported from apps/server/test (CR-014 Step 14.5): now runs on the engine.
import { content } from "@deadhead/content";
import { serverTimeSchema } from "@deadhead/schema";
import { realToGame } from "@deadhead/sim";
import { describe, expect, it } from "vitest";
import { useTestApp } from "../support";
const testApp = useTestApp();
describe("game time command (was the server time endpoint)", () => {
it("returns the engine clock's real time and the matching game time", async () => {
const fixed = Date.parse("2100-06-01T12:00:00Z");
testApp().clock.now = fixed;
const body = serverTimeSchema.parse(await testApp().app.call("getServerTime", {}));
expect(body).toEqual({ realTime: fixed, gameTime: realToGame(fixed, content.config) });
});
});