tabIndexTodoService.test.mjs
1.8 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
/**
* 待办服务单元测试
*/
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import {
sliceTodoPreview,
buildStaffRemindParams,
pickFirstMissingReceptionTodo,
shouldSkipOrderStaffPop,
shouldSkipAbnormalOrderPop
} from '../services/todoService.js'
describe('tabIndexTodoService', () => {
it('IT-TODO-001: sliceTodoPreview splits preview list', () => {
const list = [{ id: 1 }, { id: 2 }, { id: 3 }]
const result = sliceTodoPreview(list, 2)
assert.equal(result.todoList.length, 3)
assert.equal(result.stodoList.length, 2)
assert.deepEqual(result.stodoList, [{ id: 1 }, { id: 2 }])
})
it('IT-TODO-002: buildStaffRemindParams uses scene 1', () => {
const params = buildStaffRemindParams({
shopMerchantId: 'm1',
uuid: 'u1',
sceneType: 0
})
assert.deepEqual(params, {
merchantId: 'm1',
staffUuid: 'u1',
scene: 1
})
})
it('IT-TODO-003: pickFirstMissingReceptionTodo picks latest eligible', () => {
const data = [
{ missingReceptionRecord: false, hasReceptionReport: false },
{ missingReceptionRecord: true, hasReceptionReport: true },
{ missingReceptionRecord: true, hasReceptionReport: false, reportDate: '2026-06-01' }
]
const picked = pickFirstMissingReceptionTodo(data)
assert.equal(picked.length, 1)
assert.equal(picked[0].reportDate, '2026-06-01')
})
it('IT-TODO-004: shouldSkipOrderStaffPop when same day flagged', () => {
const today = new Date().toISOString().slice(0, 10)
const storage = {
date: today,
0: { m1: true }
}
assert.equal(
shouldSkipOrderStaffPop(storage, { sceneType: 0, shopMerchantId: 'm1' }),
true
)
})
it('IT-TODO-005: shouldSkipAbnormalOrderPop when not flagged', () => {
assert.equal(
shouldSkipAbnormalOrderPop({}, { sceneType: 1, shopMerchantId: 'm1' }),
false
)
})
})