39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
// Ported from apps/server/test (CR-014 Step 14.5): now runs on the engine.
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
TEST_NOW,
|
|
useTestApp,
|
|
getState,
|
|
testContract,
|
|
insertDispatch,
|
|
signUpOwner,
|
|
} from "../support";
|
|
|
|
const testApp = useTestApp();
|
|
|
|
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);
|
|
expect((await getState(app, owner)).ships[0]!.lastArrivalAt).toBe(TEST_NOW);
|
|
|
|
const out = await insertDispatch(testApp().app, {
|
|
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(testApp().app, {
|
|
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);
|
|
});
|
|
});
|