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.
chajia/__tests__/lib/mothership/portal-quote-messages.test.ts

50 lines
1.7 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 {
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("不支持附加服务");
});
});