orderApprovalFormat.test.cjs
1.63 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
const assert = require('assert')
const {
getFormattedFieldValue,
normalizeOrderGoodsPrices
} = require('../src/views/orderApproval/orderApprovalFormat')
assert.strictEqual(getFormattedFieldValue(0, 'lowPriceFlag'), '-')
assert.strictEqual(getFormattedFieldValue(1, 'lowPriceFlag'), '低价订单')
assert.strictEqual(getFormattedFieldValue(undefined, 'lowPriceFlag'), '-')
assert.strictEqual(getFormattedFieldValue(null, 'lowPriceFlag'), '-')
assert.strictEqual(getFormattedFieldValue(2, 'lowPriceFlag'), '-')
const source = {
subOrderList: [
{
upgradePrice: 1520,
singleProductSalesPrice: 999.99,
singleProductFinalPrice: 999.9900000000001
}
],
packageGoodsList: [
{
packageGoodsOrderList: [
{
finalPrice: 285.62,
number: 1,
singleProductFinalPrice: 285.62000000000006
},
{
finalPrice: 2142.74,
number: 1,
singleProductFinalPrice: 2142.74
},
{
discountType: 4,
finalPrice: 100,
singleProductFinalPrice: 100
}
]
}
]
}
const normalized = normalizeOrderGoodsPrices(source)
assert.strictEqual(normalized.subOrderList[0].singleProductFinalPrice, 999.99)
assert.strictEqual(normalized.packageGoodsList[0].packagePrice, 2428.36)
assert.strictEqual(normalized.packageGoodsList[0].packageGoodsOrderList[0].singleProductFinalPrice, 285.62)
assert.strictEqual(source.packageGoodsList[0].packagePrice, undefined)
assert.strictEqual(source.packageGoodsList[0].packageGoodsOrderList[0].singleProductFinalPrice, 285.62000000000006)
console.log('orderApprovalFormat tests passed')