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.

31 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { describe, expect, it } from "vitest";
import { mapChannel } from "@/services/parse/channel-map";
describe("channel-map", () => {
it("maps 卡派 to TRUCK", () => {
expect(mapChannel("卡派")).toEqual({ transporter: "TRUCK", unmapped: false });
});
it("maps UPS/FEDEX/DHL/USPS", () => {
expect(mapChannel("UPS Ground").transporter).toBe("UPS");
expect(mapChannel("FedEx").transporter).toBe("FEDEX");
expect(mapChannel("DHL").transporter).toBe("DHL");
expect(mapChannel("USPS").transporter).toBe("USPS");
});
it("maps 自提/留仓/扣货", () => {
expect(mapChannel("自提").transporter).toBe("自提");
expect(mapChannel("留仓").transporter).toBe("留仓");
expect(mapChannel("拦截扣货").transporter).toBe("扣货");
});
it("marks unmapped and truncates 30", () => {
const raw = "未知渠道ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const r = mapChannel(raw);
expect(r.unmapped).toBe(true);
expect(r.transporter.length).toBeLessThanOrEqual(30);
});
it("ignores Truck inside instruction note", () => {
const note =
"注意:1.ups和fedex的件... 如UPS/FEDEX/USPS/Truck 或 卡派";
expect(mapChannel(note).transporter).toBe("");
});
});