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.
61 lines
1.7 KiB
61 lines
1.7 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
evaluateMothershipAccessorialCompat,
|
|
mothershipAccessorialHasBlock,
|
|
toggleMothershipAccessorial,
|
|
} from "@/lib/mothership/option-compat";
|
|
|
|
describe("toggleMothershipAccessorial", () => {
|
|
it("禁止提货勾选住宅", () => {
|
|
const r = toggleMothershipAccessorial({
|
|
side: "pickup",
|
|
selected: ["liftgate"],
|
|
id: "residential",
|
|
});
|
|
expect(r.applied).toBe(false);
|
|
expect(r.next).toEqual(["liftgate"]);
|
|
expect(r.message).toMatch(/不支持住宅/);
|
|
});
|
|
|
|
it("预约与 Amazon 预约互斥:勾选后者去掉前者", () => {
|
|
const r = toggleMothershipAccessorial({
|
|
side: "delivery",
|
|
selected: ["appointment"],
|
|
id: "fbaAppointment",
|
|
});
|
|
expect(r.applied).toBe(true);
|
|
expect(r.next).toContain("fbaAppointment");
|
|
expect(r.next).not.toContain("appointment");
|
|
expect(r.message).toMatch(/不能同时/);
|
|
});
|
|
|
|
it("住宅与展会互斥", () => {
|
|
const r = toggleMothershipAccessorial({
|
|
side: "delivery",
|
|
selected: ["residential"],
|
|
id: "tradeshow",
|
|
});
|
|
expect(r.next).toEqual(["tradeshow"]);
|
|
});
|
|
});
|
|
|
|
describe("evaluateMothershipAccessorialCompat", () => {
|
|
it("提货已含住宅 → block", () => {
|
|
const issues = evaluateMothershipAccessorialCompat({
|
|
side: "pickup",
|
|
selected: ["residential"],
|
|
});
|
|
expect(mothershipAccessorialHasBlock(issues)).toBe(true);
|
|
});
|
|
|
|
it("住宅派送无尾板 → warn", () => {
|
|
const issues = evaluateMothershipAccessorialCompat({
|
|
side: "delivery",
|
|
selected: ["residential"],
|
|
});
|
|
expect(issues.some((i) => i.code === "ms_residential_need_liftgate")).toBe(
|
|
true,
|
|
);
|
|
});
|
|
});
|