|
|
import { describe, expect, it } from "vitest";
|
|
|
import {
|
|
|
extractMothershipPortalQuoteMessages,
|
|
|
formatMothershipPortalQuoteMessage,
|
|
|
} from "@/lib/mothership/portal-quote-messages";
|
|
|
|
|
|
describe("portal-quote-messages", () => {
|
|
|
it("合并 No rates + required fields", () => {
|
|
|
const body =
|
|
|
"Nicotine/Tobacco\nNo rates found\nPlease review all required fields to proceed.";
|
|
|
const msgs = extractMothershipPortalQuoteMessages(body);
|
|
|
expect(msgs).toContain(
|
|
|
"No rates found\nPlease review all required fields to proceed",
|
|
|
);
|
|
|
});
|
|
|
|
|
|
it("提取附加服务/住宅取件阻断(中文)", () => {
|
|
|
const body =
|
|
|
"不支持附加服务,我们的承运合作伙伴不提供住宅地址上门取件服务";
|
|
|
const msgs = extractMothershipPortalQuoteMessages(body);
|
|
|
expect(msgs.some((m) => m.includes("不支持附加服务"))).toBe(true);
|
|
|
});
|
|
|
|
|
|
it("提取 carrier partner residential pickup(英文)", () => {
|
|
|
const body =
|
|
|
"Unsupported accessorial. Our carrier partners do not provide residential pickup at this location.";
|
|
|
const msgs = extractMothershipPortalQuoteMessages(body);
|
|
|
expect(
|
|
|
msgs.some((m) =>
|
|
|
/carrier partners? do not provide/i.test(m),
|
|
|
),
|
|
|
).toBe(true);
|
|
|
});
|
|
|
|
|
|
it("format 将英文官网提示译为中文", () => {
|
|
|
const out = formatMothershipPortalQuoteMessage([
|
|
|
"No rates found",
|
|
|
"Unsupported accessorial",
|
|
|
]);
|
|
|
expect(out).toBe("未找到可用报价\n\n不支持该附加服务");
|
|
|
});
|
|
|
|
|
|
it("format 保留中文官网提示", () => {
|
|
|
const out = formatMothershipPortalQuoteMessage([
|
|
|
"不支持附加服务,承运合作伙伴不提供住宅地址上门取件",
|
|
|
]);
|
|
|
expect(out).toContain("不支持附加服务");
|
|
|
});
|
|
|
});
|