receptionListService.test.mjs
2.43 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
/**
* IT-EQ-REC-* 权益首页接待列表 service 单测
*/
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import {
buildReceptionQueryParams,
normalizeReceptionDateSections,
mergeReceptionDetails,
computeReceptionHasMore,
buildReceptionFingerprint
} from '../services/receptionListService.js'
const hasPermission = {
isSuper: () => false,
canSelectMultiStore: () => false
}
describe('receptionListService', () => {
it('IT-EQ-REC-001: buildReceptionQueryParams staff single store', () => {
const params = buildReceptionQueryParams({
violationStatus: 1,
userInfo: {
uuid: 'u1',
default4SStoreInfo: { merchantId: 'mid1' }
},
hasPermission,
searchForm: {},
storeRangeList: []
})
assert.equal(params.violationStatus, 1)
assert.deepEqual(params.merchantNo, ['mid1'])
assert.deepEqual(params.staffUuids, ['u1'])
})
it('IT-EQ-REC-002: buildReceptionQueryParams orderResult filters', () => {
const params = buildReceptionQueryParams({
isFilterDefeat: true,
isFilterUpgrade: true,
violationStatus: 0,
userInfo: { uuid: 'u1' },
hasPermission: { isSuper: () => false, canSelectMultiStore: () => true },
searchForm: {}
})
assert.deepEqual(params.orderResult, [2, 1])
})
it('IT-EQ-REC-003: normalizeReceptionDateSections', () => {
const out = normalizeReceptionDateSections([
{ staticDate: '2026-06-09' }
])
assert.equal(out[0].staticDateStr, '6月9日')
assert.deepEqual(out[0].receptionStaticInfoDTOList, [])
})
it('IT-EQ-REC-004: mergeReceptionDetails dedupes by fileUrl', () => {
const listData = [
{
staticDate: '2026-06-09',
receptionStaticInfoDTOList: [{ fileUrl: 'a' }]
}
]
const merged = mergeReceptionDetails(listData, [
{ staticDate: '2026-06-09', fileUrl: 'b' },
{ staticDate: '2026-06-09', fileUrl: 'a' }
])
assert.equal(merged[0].receptionStaticInfoDTOList.length, 2)
})
it('IT-EQ-REC-005: computeReceptionHasMore when pages reached', () => {
const listData = [{ receptionStaticInfoDTOList: [{}, {}] }]
assert.equal(computeReceptionHasMore(listData, 2, 2, 10), true)
})
it('IT-EQ-REC-006: buildReceptionFingerprint changes on violationStatus', () => {
const ctx = {
userInfo: { default4SStoreInfo: { merchantId: 'm1' } },
violationStatus: 1,
searchForm: {}
}
const a = buildReceptionFingerprint(ctx)
const b = buildReceptionFingerprint({ ...ctx, violationStatus: 0 })
assert.notEqual(a, b)
})
})