54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
import { pilotExtras } from "./fixtures";
|
|
import type { Pilot } from "@deadhead/schema";
|
|
import { screen } from "@testing-library/react";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { useClock } from "../src/clock/clock";
|
|
import { fakeApi, renderApp, samplePlayerState } from "./render";
|
|
|
|
const NOW = Date.parse("2100-01-01T00:00:00Z");
|
|
|
|
const pilot = (id: string, name: string, extra: Partial<Pilot> = {}): Pilot => ({
|
|
id,
|
|
name,
|
|
isAvatar: false,
|
|
isVeteran: false,
|
|
xp: 0,
|
|
level: 0,
|
|
skills: {},
|
|
skillPointsAvailable: 0,
|
|
assignedShipId: null,
|
|
status: "idle",
|
|
locationId: "earth",
|
|
dutyHours: 0,
|
|
dutyLimit: 12,
|
|
resting: false,
|
|
restEndsAt: null,
|
|
...pilotExtras,
|
|
...extra,
|
|
});
|
|
|
|
const pilots = [
|
|
pilot("p-rae", "Rae Okafor", { resting: true, restEndsAt: NOW + 40 * 60_000 }),
|
|
pilot("p-jun", "Jun Sato", { resting: true, restEndsAt: NOW + 9 * 60_000 }),
|
|
pilot("p-cy", "Cy Fresh"),
|
|
];
|
|
|
|
describe("rest in summaries and on HQ (Step 10D.9)", () => {
|
|
beforeEach(() => {
|
|
vi.useFakeTimers({ toFake: ["Date", "setInterval", "clearInterval"] });
|
|
vi.setSystemTime(NOW);
|
|
useClock.setState({ offsetMs: 0, synced: true, now: NOW });
|
|
});
|
|
afterEach(() => vi.useRealTimers());
|
|
|
|
it("shows how many pilots are resting and who wakes first", async () => {
|
|
renderApp(
|
|
fakeApi({ getPlayerState: () => samplePlayerState({ tutorial: null, pilots }) }),
|
|
"/",
|
|
);
|
|
const card = await screen.findByLabelText("Pilot rest");
|
|
expect(card).toHaveTextContent("Pilots resting: 2");
|
|
expect(card).toHaveTextContent("Jun Sato wakes in 9m 00s");
|
|
});
|
|
});
|