orderListRowDisplay.spec.js
2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import {
formatActualDeliveryDate,
formatCustomerTags,
mapCarDamageListRow,
mapOrderListRow,
} from "./orderListRowDisplay";
describe("订单列表日报字段显示", () => {
it("将数字日报标签转换为中文并保留中文标签", () => {
expect(formatCustomerTags("1,2,已交付引荐,5"))
.toBe("已触客,已拉群,已交付引荐,事故车客户");
});
it("兼容中文逗号并保留未知标签", () => {
expect(formatCustomerTags("1,新增标签,3"))
.toBe("已触客,新增标签,已交付引荐");
});
it("将实际交付时间格式化为日期", () => {
expect(formatActualDeliveryDate(1786934049000)).toBe("2026-08-17");
});
it("空值和无效日期显示横线", () => {
expect(formatCustomerTags(null)).toBe("-");
expect(formatActualDeliveryDate(null)).toBe("-");
expect(formatActualDeliveryDate("invalid")).toBe("-");
});
it("精品和权益行映射输出相同日报字段", () => {
const row = {
actualDeliveryDate: 1786934049000,
customerTags: "1,3",
};
expect(mapOrderListRow(row, { maps: {} })).toMatchObject({
actualDeliveryDateDisplay: "2026-08-17",
customerTagsDisplay: "已触客,已交付引荐",
});
expect(mapCarDamageListRow(row, { maps: {} })).toMatchObject({
actualDeliveryDateDisplay: "2026-08-17",
customerTagsDisplay: "已触客,已交付引荐",
});
});
it("精品订单聚合所有子订单商品名称", () => {
const row = mapOrderListRow({
subOrderList: [
{
upgradeGoodsId: 1,
upgradeGoodsName: "升级商品A",
},
{
baseGoodsName: "基础商品B",
},
],
}, { maps: {} });
expect(row.goodsNamesDisplay).toBe("升级商品A、基础商品B");
});
it("权益订单聚合所有子订单商品名称", () => {
const row = mapCarDamageListRow({
subOrderList: [
{
upgradeGoodsId: 1,
upgradeGoodsName: "权益商品A",
},
{
baseGoodsName: "权益商品B",
},
],
}, { maps: {} });
expect(row.goodsNamesDisplay).toBe("权益商品A、权益商品B");
});
});