22 lines
1.5 KiB
TypeScript
22 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { commissionRequestIssues } from "./request-validation";
|
|
import type { CommissionRequest } from "./request";
|
|
|
|
const member = (key: string) => ({ characterKey: key, weaponKey: "weapon", artifactKey: "artifact", constellation: "0", refinement: "1" } as const);
|
|
|
|
describe("commission request feedback", () => {
|
|
it("identifies each missing selection so errors can appear beside their pickers", () => {
|
|
const request: CommissionRequest = { teams: [{ members: [member("a"), member("b"), { ...member("c"), weaponKey: "", artifactKey: "" }, member("d")] }], weapons: [], constellations: [] };
|
|
expect(commissionRequestIssues(request)).toEqual([
|
|
{ path: "teams.0.members.2.weaponKey", message: "ทีม 1: เลือกอาวุธให้ตัวละครที่ 3" },
|
|
{ path: "teams.0.members.2.artifactKey", message: "ทีม 1: เลือกอาร์ติแฟกต์ให้ตัวละครที่ 3" },
|
|
]);
|
|
});
|
|
it("reports duplicate characters at their team rather than at an unrelated picker", () => {
|
|
expect(commissionRequestIssues({ teams: [{ members: [member("a"), member("a"), member("c"), member("d")] }], weapons: [], constellations: [] })[0].path).toBe("teams.0");
|
|
});
|
|
it("accepts a valid comparison without requiring a team", () => {
|
|
expect(commissionRequestIssues({ teams: [], weapons: [{ characterKey: "a", weaponKeys: ["one", "two"] }], constellations: [] })).toEqual([]);
|
|
});
|
|
});
|