100 lines
2.9 KiB
JavaScript
100 lines
2.9 KiB
JavaScript
describe('tcm support pages', () => {
|
|
afterEach(() => {
|
|
delete global.Page
|
|
delete global.wx
|
|
jest.resetModules()
|
|
})
|
|
|
|
test('assets page switches by static kind and keeps route-only navigation', () => {
|
|
let capturedPageConfig
|
|
|
|
global.Page = config => {
|
|
capturedPageConfig = config
|
|
}
|
|
|
|
const assetsPageModule = require('../packages/tcm/pages/assets/index')
|
|
const pageData = assetsPageModule.createTcmAssetsPageData('favorites')
|
|
|
|
expect(capturedPageConfig.data).toEqual(expect.objectContaining({ activeKind: 'notes' }))
|
|
expect(pageData.activeKind).toBe('favorites')
|
|
expect(pageData.title).toBe('学习资产')
|
|
expect(pageData.filterItems).toHaveLength(4)
|
|
})
|
|
|
|
test('routes TCM asset history items back to the AI tab with switchTab', () => {
|
|
let capturedPageConfig
|
|
|
|
global.Page = config => {
|
|
capturedPageConfig = config
|
|
}
|
|
|
|
global.wx = {
|
|
switchTab: jest.fn(),
|
|
navigateTo: jest.fn()
|
|
}
|
|
|
|
const assetsPageModule = require('../packages/tcm/pages/assets/index')
|
|
const pageData = assetsPageModule.createTcmAssetsPageData('history')
|
|
|
|
capturedPageConfig.handleEntryTap({
|
|
currentTarget: {
|
|
dataset: {
|
|
route: pageData.items[0].route
|
|
}
|
|
}
|
|
})
|
|
|
|
expect(global.wx.switchTab).toHaveBeenCalledWith({
|
|
url: '/pages/ai/index'
|
|
})
|
|
expect(global.wx.navigateTo).not.toHaveBeenCalled()
|
|
})
|
|
|
|
test('ai history, bianzheng and placeholder pages expose scene-driven static data', () => {
|
|
global.Page = () => {}
|
|
|
|
const aiHistoryModule = require('../packages/tcm/pages/ai-history/index')
|
|
const bianzhengModule = require('../packages/tcm/pages/bianzheng/index')
|
|
const placeholderModule = require('../packages/tcm/pages/placeholder/index')
|
|
|
|
expect(aiHistoryModule.createTcmAiHistoryPageData('empty')).toEqual(
|
|
expect.objectContaining({ scene: 'empty', title: 'AI对话历史' })
|
|
)
|
|
expect(bianzhengModule.createTcmBianzhengPageData('result')).toEqual(
|
|
expect.objectContaining({ scene: 'result', title: '辨证分析' })
|
|
)
|
|
expect(placeholderModule.createTcmPlaceholderPageData('membership')).toEqual(
|
|
expect.objectContaining({ kind: 'membership' })
|
|
)
|
|
})
|
|
|
|
test('routes AI history items targeting the AI tab with switchTab', () => {
|
|
let capturedPageConfig
|
|
|
|
global.Page = config => {
|
|
capturedPageConfig = config
|
|
}
|
|
|
|
global.wx = {
|
|
switchTab: jest.fn(),
|
|
navigateTo: jest.fn()
|
|
}
|
|
|
|
const aiHistoryModule = require('../packages/tcm/pages/ai-history/index')
|
|
const pageData = aiHistoryModule.createTcmAiHistoryPageData('default')
|
|
|
|
capturedPageConfig.handleHistoryTap({
|
|
currentTarget: {
|
|
dataset: {
|
|
route: pageData.groups[0].items[0].route
|
|
}
|
|
}
|
|
})
|
|
|
|
expect(global.wx.switchTab).toHaveBeenCalledWith({
|
|
url: '/pages/ai/index'
|
|
})
|
|
expect(global.wx.navigateTo).not.toHaveBeenCalled()
|
|
})
|
|
})
|