You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
888 B
34 lines
888 B
import { describe, expect, it } from "vitest";
|
|
import { parseMarkupInput } from "@/modules/pricing/markup-validation";
|
|
|
|
describe("parseMarkupInput", () => {
|
|
it("默认百分比模式", () => {
|
|
const result = parseMarkupInput({ markup_percent: 10 });
|
|
expect(result).toEqual({
|
|
markupType: "percent",
|
|
markupPercent: 10,
|
|
markupFixedAmount: null,
|
|
});
|
|
});
|
|
|
|
it("固定金额模式", () => {
|
|
const result = parseMarkupInput({
|
|
markup_type: "fixed",
|
|
markup_fixed_amount: 50.5,
|
|
});
|
|
expect(result).toEqual({
|
|
markupType: "fixed",
|
|
markupPercent: 0,
|
|
markupFixedAmount: 50.5,
|
|
});
|
|
});
|
|
|
|
it("比例超过 30% 拒绝", () => {
|
|
const result = parseMarkupInput({ markup_percent: 30.1 });
|
|
expect(result).toMatchObject({
|
|
code: "PERCENT_TOO_HIGH",
|
|
message: "加价比例不能超过 30%",
|
|
});
|
|
});
|
|
});
|