carDamageListRowDisplay.spec.js
3.23 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const {
resolveRightsSceneLabel,
mapCarDamageSubOrderDisplayItem,
mapCarDamageListRow,
} = require("@/views/orderManage/utils/orderListRowDisplay");
describe("carDamageListRowDisplay", () => {
describe("resolveRightsSceneLabel", () => {
const sceneList = [
{ baseSceneCode: "SC001", name: "场景一" },
];
it("matches scene from list by baseSceneCode", () => {
expect(resolveRightsSceneLabel({ baseSceneCode: "SC001" }, sceneList)).toBe("场景一");
});
it("falls back to baseSceneCode when not in list", () => {
expect(resolveRightsSceneLabel({ baseSceneCode: "SC999" }, sceneList)).toBe("SC999");
});
it("falls back to baseSceneName", () => {
expect(resolveRightsSceneLabel({ baseSceneName: "备用名称" }, sceneList)).toBe("备用名称");
});
it("returns dash for empty row", () => {
expect(resolveRightsSceneLabel(null, sceneList)).toBe("-");
});
});
describe("mapCarDamageSubOrderDisplayItem", () => {
it("precomputes package and coupon fields", () => {
const item = mapCarDamageSubOrderDisplayItem({
upgradeGoodsId: 1,
packageName: "权益套餐A",
packageAlias: "别名一二三四五六七八九十",
upgradeGoodsName: "商品名",
upgradePrice: 100,
singleProductSalesPrice: 90,
singleProductFinalPrice: 80,
number: 1,
discountAmount: 5,
upgradeWarrantyPeriod: 2,
upgradeGoodsAlias: "商品别名",
coupon: {
customerCouponCode: "CP001",
couponName: "满减券名称很长很长很长",
discountPrice: 10,
},
}, []);
expect(item.packageNameDisplay).toBe("权益套餐A");
expect(item.packageAliasDisplay).toBe("别名一二三四五六七八...");
expect(item.couponCodeDisplay).toBe("CP001");
expect(item.couponNameDisplay).toBe("满减券名称很长很长很...");
expect(item.couponAmountDisplay).toBe("10");
});
});
describe("mapCarDamageListRow", () => {
const maps = {
statusOpts: { 4: "已支付" },
upgradeOpts: { Y: "已升级" },
profitAllocationStatusOpts: { 1: "未分账" },
invoiceStatusOpts: { 1: "未开票" },
zyVoucherStatusOpts: { 1: "待上传" },
saleFlagTextObj: { 1: "直营" },
djOrderTypeMap: { 1: "普通" },
auditStatusMap: { 3: "已通过" },
positionTypeList: [],
rightsSceneListForSearch: [{ baseSceneCode: "SC001", name: "场景一" }],
};
it("maps car damage row with rights-specific labels", () => {
const row = mapCarDamageListRow({
djOrderType: 1,
goodsOrderApplyStatus: 3,
status: 4,
upgradeFlag: "Y",
profitAllocationStatus: 1,
invoiceStatus: 1,
zyVoucherStatus: 1,
directSalesFlag: 1,
salesType: 0,
source: 7,
baseSceneCode: "SC001",
subOrderList: [{ packageName: "套餐1", baseGoodsName: "商品A" }],
}, { maps });
expect(row.salesTypeLabel).toBe("门店引流 - 售前");
expect(row.rightsSceneDisplayLabel).toBe("场景一");
expect(row.zyVoucherStatusLabel).toBe("待上传");
expect(row.customerSexLabel).toBe("-");
expect(row.subOrderCount).toBe(1);
expect(row.subOrderDisplayList).toHaveLength(1);
});
it("maps customer sex when present", () => {
const row = mapCarDamageListRow({ customerSex: 2, subOrderList: [] }, { maps });
expect(row.customerSexLabel).toBe("女");
});
});
});