tabIndexMenuJump.test.mjs
1.49 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
/**
* jumpHandlers 单元测试(IT-MENU-JUMP-*)
*/
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { setupWxMock } from './menuTestHelpers.mjs'
const globalRef = globalThis
describe('tabIndexMenuJump', async () => {
setupWxMock(globalRef)
const { resolveActionType } = await import('../menu/resolveActionType.js')
it('IT-MENU-JUMP-001: resolveActionType prefers action.type', () => {
assert.equal(
resolveActionType({ action: { type: 'salaryPerformance' } }),
'salaryPerformance'
)
})
it('IT-MENU-JUMP-002: workReport from reportTypeAttr', () => {
assert.equal(
resolveActionType({
reportTypeAttr: 'daily',
url: 'tabWorkOrder.supervisorDaily'
}),
'workReport'
)
})
it('IT-MENU-JUMP-003: switchTab from repair order flag', () => {
assert.equal(
resolveActionType({ isRepairOrderTabFromMenu: true }),
'switchTab'
)
})
it('IT-MENU-JUMP-004: navigate from navigateToUrl', () => {
assert.equal(
resolveActionType({
navigateToUrl: '/packageEquity/pages/sceneMarket/index/index'
}),
'navigate'
)
})
it('IT-MENU-JUMP-005: router fallback without name inference', () => {
assert.equal(
resolveActionType({ id: 'training_materials', path: 'packageEquity.trainingMaterials' }),
'router'
)
})
it('IT-MENU-JUMP-006: scanCode and miniProgram types', () => {
assert.equal(resolveActionType({ type: 'scanCode' }), 'scanCode')
assert.equal(resolveActionType({ type: 'mini' }), 'miniProgram')
})
})