submitGoodsSnapshot.test.mjs
1.52 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
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { buildSubmitGoodsSnapshot } from '../services/submitGoodsSnapshot.js'
describe('submitGoodsSnapshot', () => {
it('maps goodsList approval and subOrder fields', () => {
const snapshot = buildSubmitGoodsSnapshot(
{
goodsList: [
{
goodsFlag: 1,
count: 2,
marketingFlag: 1,
activityId: 9,
goods: {
sellPrice: 100,
activitySellPrice: 299,
marketingFlag: 1,
activityId: 9,
validMinSellPrice: 'Y',
minSellPrice: 200
}
}
],
orderObj: {
subOrderList: [
{
merchantGoodsId: 1,
totalPrice: 100,
finalPrice: 200,
marketingFlag: 1,
activityId: 9,
modifyFlag: 1,
number: 2
}
]
}
},
{
approvalItems: [
{
type: 'single',
name: '太阳膜',
activityPrice: 299,
totalPrice: 100,
marketingFlag: 1
}
]
}
)
assert.equal(snapshot.goodsList.length, 1)
assert.equal(snapshot.goodsList[0].goods.activitySellPrice, 299)
assert.equal(snapshot.approvalItems[0].activityPrice, 299)
assert.equal(snapshot.subOrderList[0].marketingFlag, 1)
assert.equal(snapshot.subOrderList[0].activityId, 9)
})
})