yongren-routes.test.ts 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // 在导入 app.config.ts 之前定义全局 defineAppConfig 函数
  2. // @ts-ignore
  3. global.defineAppConfig = (config: any) => config
  4. // 现在导入实际的配置文件
  5. import appConfig from '../src/app.config'
  6. describe('用人方小程序路由配置(实际测试配置文件)', () => {
  7. test('应包含7个用人方小程序页面', () => {
  8. const yongrenPages = appConfig.pages.filter((page: string) => page.includes('yongren'))
  9. expect(yongrenPages).toHaveLength(7)
  10. })
  11. test('用人方页面应位于页面列表开头', () => {
  12. // 检查前7个页面都是用人方页面
  13. const firstSevenPages = appConfig.pages.slice(0, 7)
  14. const allAreYongren = firstSevenPages.every(page => page.includes('yongren'))
  15. expect(allAreYongren).toBe(true)
  16. })
  17. test('应包含正确的页面路径', () => {
  18. const expectedPages = [
  19. 'pages/yongren/dashboard/index',
  20. 'pages/yongren/talent/list/index',
  21. 'pages/yongren/talent/detail/index',
  22. 'pages/yongren/order/list/index',
  23. 'pages/yongren/order/detail/index',
  24. 'pages/yongren/statistics/index',
  25. 'pages/yongren/settings/index',
  26. ]
  27. expectedPages.forEach(page => {
  28. expect(appConfig.pages).toContain(page)
  29. })
  30. })
  31. test('现有页面不应被移除', () => {
  32. const existingPages = [
  33. 'pages/profile/index',
  34. 'pages/login/index',
  35. ]
  36. existingPages.forEach(page => {
  37. expect(appConfig.pages).toContain(page)
  38. })
  39. })
  40. test('tabBar配置应正确设置', () => {
  41. expect(appConfig.tabBar.custom).toBe(true)
  42. expect(appConfig.tabBar.color).toBe('#6b7280')
  43. expect(appConfig.tabBar.selectedColor).toBe('#3b82f6')
  44. expect(appConfig.tabBar.backgroundColor).toBe('#ffffff')
  45. expect(appConfig.tabBar.list).toHaveLength(5)
  46. // 检查tabBar项目
  47. const tabBarItems = appConfig.tabBar.list
  48. expect(tabBarItems[0].pagePath).toBe('pages/yongren/dashboard/index')
  49. expect(tabBarItems[0].text).toBe('首页')
  50. expect(tabBarItems[1].pagePath).toBe('pages/yongren/talent/list/index')
  51. expect(tabBarItems[1].text).toBe('人才')
  52. expect(tabBarItems[2].pagePath).toBe('pages/yongren/order/list/index')
  53. expect(tabBarItems[2].text).toBe('订单')
  54. expect(tabBarItems[3].pagePath).toBe('pages/yongren/statistics/index')
  55. expect(tabBarItems[3].text).toBe('数据')
  56. expect(tabBarItems[4].pagePath).toBe('pages/profile/index')
  57. expect(tabBarItems[4].text).toBe('设置')
  58. })
  59. test('window配置应正确设置', () => {
  60. expect(appConfig.window.navigationBarBackgroundColor).toBe('#3b82f6')
  61. expect(appConfig.window.navigationBarTitleText).toBe('用人方小程序')
  62. expect(appConfig.window.backgroundTextStyle).toBe('light')
  63. expect(appConfig.window.navigationBarTextStyle).toBe('white')
  64. expect(appConfig.window.navigationStyle).toBe('custom')
  65. })
  66. test('第一个页面应为仪表板页面', () => {
  67. expect(appConfig.pages[0]).toBe('pages/yongren/dashboard/index')
  68. })
  69. test('tabBar页面应正确对应实际页面', () => {
  70. const tabBarPaths = appConfig.tabBar.list.map(item => item.pagePath)
  71. // 所有tabBar路径都应在pages列表中
  72. tabBarPaths.forEach(path => {
  73. expect(appConfig.pages).toContain(path)
  74. })
  75. })
  76. })