selectedMerchantContext.integration.test.mjs
2.54 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
import assert from 'node:assert/strict'
import { register } from 'node:module'
import test from 'node:test'
register(
'../../../../tests/work-order-migration/shims/create-order-context-loader.mjs',
import.meta.url
)
test('customer or history echo keeps the store selected before low-price order creation', async () => {
let pageConfig
globalThis.getApp = () => ({ globalData: {} })
globalThis.Page = config => {
pageConfig = config
}
globalThis.wx = {
getAccountInfoSync: () => ({
miniProgram: { appId: 'test-app-id', envVersion: 'develop' }
}),
getSystemInfoSync: () => ({ platform: 'devtools' }),
getStorageSync: () => '',
setNavigationBarTitle: () => {},
enableAlertBeforeUnload: () => {},
$util: {
getUserInfo: () => ({}),
showLoading: () => {}
}
}
await import(`../createOrder.js?selected-merchant=${Date.now()}`)
const selectedStore = {
lowPriceFlag: 1,
merchantId: 201,
merchantName: '已选4S店',
yqMerchantId: 100,
yqMerchantName: '已选园区店',
sellerMerchantId: 100,
sellerMerchantName: '已选园区店'
}
const page = {
_isLowPriceCreateOrder: true,
isLowPriceOrder: pageConfig.isLowPriceOrder,
data: {
...pageConfig.data,
orderObj: { ...pageConfig.data.orderObj, ...selectedStore },
orderTypeList: [{ text: '精品订单', value: 1 }]
},
setData(patch, callback) {
Object.assign(this.data, patch)
callback?.()
},
echoCustomerProfileIfNeeded: async () => {},
getSelectOrderGoodsList: () => {}
}
const incoming = {
lowPriceFlag: 1,
merchantId: 999,
merchantName: '档案所属4S店',
yqMerchantId: 888,
yqMerchantName: '档案所属园区店',
sellerMerchantId: 888,
sellerMerchantName: '档案所属园区店',
djOrderType: 1,
customer: {
customerName: '张三',
customerSex: 1,
experienceFlag: 'Y',
salesType: 0
}
}
pageConfig.setOrderObj.call(page, incoming)
assert.equal(page.data.orderTypeName, '低价订单')
assert.equal(page.data.orderObj.customer.customerName, '张三')
assert.deepEqual(
{
lowPriceFlag: page.data.orderObj.lowPriceFlag,
merchantId: page.data.orderObj.merchantId,
merchantName: page.data.orderObj.merchantName,
yqMerchantId: page.data.orderObj.yqMerchantId,
yqMerchantName: page.data.orderObj.yqMerchantName,
sellerMerchantId: page.data.orderObj.sellerMerchantId,
sellerMerchantName: page.data.orderObj.sellerMerchantName
},
selectedStore
)
})