| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- // 在导入 app.config.ts 之前定义全局 defineAppConfig 函数
- global.defineAppConfig = (config: any) => config
- // 现在导入实际的配置文件
- import appConfig from '../src/app.config'
- describe('用人方小程序路由配置(实际测试配置文件)', () => {
- test('应包含7个用人方小程序页面', () => {
- const yongrenPages = appConfig.pages.filter((page: string) => page.includes('yongren'))
- expect(yongrenPages).toHaveLength(7)
- })
- test('用人方页面应位于页面列表开头', () => {
- // 检查前7个页面都是用人方页面
- const firstSevenPages = appConfig.pages.slice(0, 7)
- const allAreYongren = firstSevenPages.every(page => page.includes('yongren'))
- expect(allAreYongren).toBe(true)
- })
- test('应包含正确的页面路径', () => {
- const expectedPages = [
- 'pages/yongren/dashboard/index',
- 'pages/yongren/talent/list/index',
- 'pages/yongren/talent/detail/index',
- 'pages/yongren/order/list/index',
- 'pages/yongren/order/detail/index',
- 'pages/yongren/statistics/index',
- 'pages/yongren/settings/index',
- ]
- expectedPages.forEach(page => {
- expect(appConfig.pages).toContain(page)
- })
- })
- test('现有页面不应被移除', () => {
- const existingPages = [
- 'pages/profile/index',
- 'pages/login/index',
- ]
- existingPages.forEach(page => {
- expect(appConfig.pages).toContain(page)
- })
- })
- test('tabBar配置应正确设置', () => {
- expect(appConfig.tabBar.custom).toBe(true)
- expect(appConfig.tabBar.color).toBe('#6b7280')
- expect(appConfig.tabBar.selectedColor).toBe('#3b82f6')
- expect(appConfig.tabBar.backgroundColor).toBe('#ffffff')
- expect(appConfig.tabBar.list).toHaveLength(5)
- // 检查tabBar项目
- const tabBarItems = appConfig.tabBar.list
- expect(tabBarItems[0].pagePath).toBe('pages/yongren/dashboard/index')
- expect(tabBarItems[0].text).toBe('首页')
- expect(tabBarItems[1].pagePath).toBe('pages/yongren/talent/list/index')
- expect(tabBarItems[1].text).toBe('人才')
- expect(tabBarItems[2].pagePath).toBe('pages/yongren/order/list/index')
- expect(tabBarItems[2].text).toBe('订单')
- expect(tabBarItems[3].pagePath).toBe('pages/yongren/statistics/index')
- expect(tabBarItems[3].text).toBe('数据')
- expect(tabBarItems[4].pagePath).toBe('pages/profile/index')
- expect(tabBarItems[4].text).toBe('设置')
- })
- test('window配置应正确设置', () => {
- expect(appConfig.window.navigationBarBackgroundColor).toBe('#3b82f6')
- expect(appConfig.window.navigationBarTitleText).toBe('用人方小程序')
- expect(appConfig.window.backgroundTextStyle).toBe('light')
- expect(appConfig.window.navigationBarTextStyle).toBe('white')
- expect(appConfig.window.navigationStyle).toBe('custom')
- })
- test('第一个页面应为仪表板页面', () => {
- expect(appConfig.pages[0]).toBe('pages/yongren/dashboard/index')
- })
- test('tabBar页面应正确对应实际页面', () => {
- const tabBarPaths = appConfig.tabBar.list.map(item => item.pagePath)
- // 所有tabBar路径都应在pages列表中
- tabBarPaths.forEach(path => {
- expect(appConfig.pages).toContain(path)
- })
- })
- })
|