35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { TEST_NOW, useTestDatabase } from "./db";
|
|
import { getState, insertDispatch, signUpOwner, testContract, useTestApp } from "./game";
|
|
|
|
const database = useTestDatabase();
|
|
const testApp = useTestApp(database);
|
|
|
|
describe("ship lastArrivalAt (CR-002)", () => {
|
|
it("is the delivery time before a flight and the latest arrival after flights", async () => {
|
|
const { app, clock } = testApp();
|
|
const owner = await signUpOwner(app, database().db);
|
|
expect((await getState(app, owner)).ships[0]!.lastArrivalAt).toBe(TEST_NOW);
|
|
|
|
const out = await insertDispatch(database().db, {
|
|
playerId: owner.playerId,
|
|
shipId: owner.shipId,
|
|
pilotId: owner.avatarId,
|
|
departAt: clock.now,
|
|
contract: testContract(),
|
|
});
|
|
clock.now = out.arrivalAt;
|
|
expect((await getState(app, owner)).ships[0]!.lastArrivalAt).toBe(out.arrivalAt);
|
|
|
|
const back = await insertDispatch(database().db, {
|
|
playerId: owner.playerId,
|
|
shipId: owner.shipId,
|
|
pilotId: owner.avatarId,
|
|
departAt: clock.now,
|
|
contract: testContract({ originId: "moon", destinationId: "earth" }),
|
|
});
|
|
clock.now = back.arrivalAt + 1000;
|
|
expect((await getState(app, owner)).ships[0]!.lastArrivalAt).toBe(back.arrivalAt);
|
|
});
|
|
});
|