| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- // 在导入 app.config.ts 之前定义全局 defineAppConfig 函数
- global.defineAppConfig = (config: any) => config
- // 现在导入实际的配置文件
- import appConfig from '../src/app.config'
- describe('用人方小程序路由配置(实际测试配置文件)', () => {
- test('应包含8个用人方小程序页面', () => {
- const yongrenPages = appConfig.pages.filter((page: string) => page.includes('yongren'))
- expect(yongrenPages).toHaveLength(8)
- })
- test('用人方页面应位于页面列表开头', () => {
- // 检查前8个页面都是用人方页面
- const firstEightPages = appConfig.pages.slice(0, 8)
- const allAreYongren = firstEightPages.every(page => page.includes('yongren'))
- expect(allAreYongren).toBe(true)
- })
- test('应包含正确的页面路径', () => {
- const expectedPages = [
- 'pages/yongren/login/index',
- '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/index/index',
- 'pages/explore/index',
- 'pages/profile/index',
- 'pages/login/index',
- 'pages/login/wechat-login',
- 'pages/register/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/yongren/settings/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/login/index')
- })
- test('tabBar页面应正确对应实际页面', () => {
- const tabBarPaths = appConfig.tabBar.list.map(item => item.pagePath)
- // 所有tabBar路径都应在pages列表中
- tabBarPaths.forEach(path => {
- expect(appConfig.pages).toContain(path)
- })
- })
- })
|