import { describe, expect, test } from "vitest";
import { appUserLevelAdjustmentSchema } from "./schema";

const adjustment = (level: string) => ({
    charm: { durationDays: "7", enabled: false, level: "" },
    reason: "运营修正",
    wealth: { durationDays: "7", enabled: true, level },
});

describe("appUserLevelAdjustmentSchema", () => {
    test("accepts the product maximum of level 100", () => {
        expect(appUserLevelAdjustmentSchema.safeParse(adjustment("100")).success).toBe(true);
    });

    test("rejects a level above 100", () => {
        const result = appUserLevelAdjustmentSchema.safeParse(adjustment("101"));
        expect(result.success).toBe(false);
        if (!result.success) {
            expect(result.error.issues).toContainEqual(expect.objectContaining({ message: "目标等级必须是 1 到 100 的整数" }));
        }
    });
});
