feat: migrate static pages to native tabbar
This commit is contained in:
43
tests/profile-page.test.js
Normal file
43
tests/profile-page.test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
describe('profile page', () => {
|
||||
afterEach(() => {
|
||||
delete global.Page
|
||||
delete global.wx
|
||||
jest.resetModules()
|
||||
})
|
||||
|
||||
test('exposes static profile sections and navigable shortcuts', () => {
|
||||
let capturedPageConfig
|
||||
|
||||
global.Page = config => {
|
||||
capturedPageConfig = config
|
||||
}
|
||||
|
||||
global.wx = {
|
||||
navigateTo: jest.fn()
|
||||
}
|
||||
|
||||
const profilePageModule = require('../pages/profile/index')
|
||||
const pageData = profilePageModule.createProfilePageData()
|
||||
|
||||
expect(pageData.userCard.title).toBe('点击登录')
|
||||
expect(pageData.assetItems).toHaveLength(4)
|
||||
expect(pageData.moreItems).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ key: 'learning-center', title: '学习中心' }),
|
||||
expect.objectContaining({ key: 'ai-history', title: 'AI历史' })
|
||||
])
|
||||
)
|
||||
|
||||
capturedPageConfig.handleMoreTap({
|
||||
currentTarget: {
|
||||
dataset: {
|
||||
route: '/packages/learning/pages/center/index'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
expect(global.wx.navigateTo).toHaveBeenCalledWith({
|
||||
url: '/packages/learning/pages/center/index'
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user