Files
inquiry_robot/inquiry-backend/tests/demandFields.spec.ts
T

64 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { buildDemandFields, quantitySummary } from "/@/views/inquiry/workOrder/demandFields";
test("land FTL shows vehicle not pieces", () => {
const rows = buildDemandFields({
businessLine: "LAND",
bizTypeLabel: "陆运",
origin: "上海",
destination: "春疆货场",
goodsName: "茶叶",
factsJson: JSON.stringify({
运输类型: "国内运输整车",
线路类别: "国内长途/零担",
运输分类: "普件",
"车型/数量": "53尺(16.5厢车)",
起运港: "上海",
目的港: "春疆货场",
品名: "茶叶",
报价日期: "2026-10-03",
}),
});
const map = Object.fromEntries(rows.map((r) => [r.label, r.value]));
expect(map["运输方式"]).toBe("陆运");
expect(map["运输类型"]).toBe("国内运输整车");
expect(map["车型/数量"]).toBe("53尺(16.5厢车)");
expect(map["始发站"]).toBe("上海");
expect(map["货物品名"]).toBe("茶叶");
expect(map["件数"]).toBeUndefined();
});
test("sea shows container spec", () => {
const rows = buildDemandFields({
businessLine: "SEA",
bizTypeLabel: "海运",
factsJson: JSON.stringify({
起运港: "上海",
目的港: "汉堡",
品名: "配件",
货量: "1x40HQ",
整柜或拼柜: "整柜",
箱型箱量: "40HQ*1",
贸易条款: "FOB",
运输分类: "Port to Port",
报价日期: "2026-10-03",
}),
});
const map = Object.fromEntries(rows.map((r) => [r.label, r.value]));
expect(map["箱型箱量"]).toBe("40HQ*1");
expect(map["整柜或拼柜"]).toBe("整柜");
expect(map["件数"]).toBeUndefined();
});
test("land LTL quantity summary uses volume", () => {
const qty = quantitySummary({
businessLine: "LAND",
factsJson: JSON.stringify({
运输类型: "国内运输拼车",
体积: "10CBM",
毛重: "50kg",
}),
});
expect(qty).toContain("体积(CBM) 10CBM");
expect(qty).not.toContain("车型");
});