yongren-routes.test.ts 3.3 KB

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