abnormalFlowDeclarationApi.test.mjs
1.87 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
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
describe('abnormalFlowDeclaration helpers', async () => {
const {
ABNORMAL_FLOW_TYPE,
ABNORMAL_FLOW_TYPE_LABEL,
ABNORMAL_FLOW_APPROVAL_STATUS,
DECLARATION_FLAG,
buildDeclarationSubmitParams
} = await import('../api/abnormalFlowDeclaration.helpers.js')
it('ABNORMAL_FLOW_TYPE has 7 type values', () => {
assert.equal(Object.keys(ABNORMAL_FLOW_TYPE).length, 7)
assert.equal(ABNORMAL_FLOW_TYPE_LABEL[7], '其他异常')
})
it('ABNORMAL_FLOW_APPROVAL_STATUS has 5 approval statuses', () => {
assert.equal(Object.keys(ABNORMAL_FLOW_APPROVAL_STATUS).length, 5)
assert.equal(ABNORMAL_FLOW_APPROVAL_STATUS.APPROVED, 5)
})
it('DECLARATION_FLAG defines not declared and declared', () => {
assert.equal(DECLARATION_FLAG.NOT_DECLARED, 0)
assert.equal(DECLARATION_FLAG.DECLARED, 1)
})
it('buildDeclarationSubmitParams passes required fields', () => {
const params = buildDeclarationSubmitParams({
outTradeNo: 'PAY001',
abnormalType: 1,
remark: '备注'
})
assert.deepEqual(params, {
outTradeNo: 'PAY001',
abnormalType: 1,
remark: '备注'
})
})
it('buildDeclarationSubmitParams includes voucherImageUrls when non-empty', () => {
const params = buildDeclarationSubmitParams({
outTradeNo: 'PAY001',
abnormalType: 2,
remark: 'x',
voucherImageUrls: ['https://a/1.png', '', 'https://a/2.png']
})
assert.deepEqual(params.voucherImageUrls, [
'https://a/1.png',
'https://a/2.png'
])
})
it('buildDeclarationSubmitParams omits voucherImageUrls when empty', () => {
const params = buildDeclarationSubmitParams({
outTradeNo: 'PAY001',
abnormalType: 1,
remark: 'x',
voucherImageUrls: []
})
assert.equal(params.voucherImageUrls, undefined)
})
})