22 lines
885 B
TypeScript
22 lines
885 B
TypeScript
import { describe, expect, test } from "vitest";
|
|
import { emptyLuckyGiftForm } from "@/features/lucky-gift/configModel.js";
|
|
import { luckyGiftConfigFormSchema } from "@/features/lucky-gift/schema";
|
|
|
|
describe("lucky gift config schema", () => {
|
|
test("validates enabled stage probability with backend ppm semantics", () => {
|
|
const form = emptyLuckyGiftForm();
|
|
const normal = form.stages.find((stage: { stage: string }) => stage.stage === "normal");
|
|
if (!normal) {
|
|
throw new Error("normal stage missing");
|
|
}
|
|
normal.tiers[0].enabled = false;
|
|
|
|
const result = luckyGiftConfigFormSchema.safeParse(form);
|
|
|
|
expect(result.success).toBe(false);
|
|
if (!result.success) {
|
|
expect(result.error.issues.map((issue) => issue.message)).toContain("启用奖档概率合计必须等于 100%");
|
|
}
|
|
});
|
|
});
|