orderListRowDisplay.spec.js
2.27 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
const {
truncateDisplay,
getGoodsTypeName,
mapSubOrderDisplayItem,
mapOrderListRow,
} = require("@/views/orderManage/utils/orderListRowDisplay");
describe("orderListRowDisplay", () => {
describe("truncateDisplay", () => {
it("truncates long text", () => {
expect(truncateDisplay("abcdefghijklmnop", 10)).toBe("abcdefghij...");
});
it("returns dash for empty", () => {
expect(truncateDisplay("")).toBe("-");
});
});
describe("getGoodsTypeName", () => {
it("joins type names with dash", () => {
expect(getGoodsTypeName({
upgradeGoodsTypeName: "A",
upgradeSecondaryGoodsTypeName: "B",
})).toBe("A-B");
});
});
describe("mapSubOrderDisplayItem", () => {
it("precomputes display fields", () => {
const item = mapSubOrderDisplayItem({
upgradeGoodsId: 1,
upgradeGoodsName: "超长商品名称一二三四五六七八九十",
upgradePrice: 100,
singleProductSalesPrice: 90,
singleProductFinalPrice: 80,
number: 2,
discountAmount: 5,
upgradeWarrantyPeriod: 3,
upgradeGoodsAlias: "别名",
upgradeGoodsTypeName: "贴膜",
}, []);
expect(item.goodsNameDisplay).toBe("超长商品名称一二三四...");
expect(item.goodsTypeDisplay).toBe("贴膜");
expect(item.unitPriceDisplay).toBe("¥ 100");
expect(item.warrantyDisplay).toBe("3年");
});
});
describe("mapOrderListRow", () => {
const maps = {
statusOpts: { 4: "已支付" },
upgradeOpts: { Y: "已升级" },
profitAllocationStatusOpts: { 1: "未分账" },
invoiceStatusOpts: { 1: "未开票" },
saleFlagTextObj: { 1: "直营" },
djOrderTypeMap: { 1: "普通" },
auditStatusMap: { 3: "已通过" },
positionTypeList: [],
};
it("maps order row display labels", () => {
const row = mapOrderListRow({
djOrderType: 1,
goodsOrderApplyStatus: 3,
status: 4,
upgradeFlag: "Y",
profitAllocationStatus: 1,
invoiceStatus: 1,
directSalesFlag: 1,
salesType: 0,
source: 7,
subOrderList: [{ baseGoodsName: "商品A" }],
packageGoodsList: [{ packageName: "套餐1" }],
}, { maps });
expect(row.statusLabel).toBe("已支付");
expect(row.orderSourceLabel).toBe("系统导入");
expect(row.subOrderDisplayList).toHaveLength(1);
expect(row.packageNamesDisplay).toBe("套餐1");
});
});
});