deadhead-space-freight-tycoon/apps/server/test/board-keys.test.ts

31 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { useTestDatabase } from "./db";
import { putBoard, signUp, testContract, useTestApp } from "./game";
const database = useTestDatabase();
const testApp = useTestApp(database);
describe("contract boards keyed by location (CR-002)", () => {
it("lets one player have boards at two locations in the same period", async () => {
const { db } = database();
const guest = await signUp(testApp().app);
await putBoard(db, guest.playerId, [testContract()], undefined, "earth");
await putBoard(
db,
guest.playerId,
[testContract({ originId: "moon", destinationId: "earth" })],
undefined,
"moon",
);
});
it("rejects a second board for the same player, location and period", async () => {
const { db } = database();
const guest = await signUp(testApp().app);
await putBoard(db, guest.playerId, [testContract()], undefined, "moon");
await expect(
putBoard(db, guest.playerId, [testContract()], undefined, "moon"),
).rejects.toThrow();
});
});