| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /**
- * EmploymentHistory组件测试
- */
- import React from 'react'
- import { render, screen } from '@testing-library/react'
- import '@testing-library/jest-dom'
- import { EmploymentHistory } from '@/components/EmploymentHistory'
- import { WorkStatus } from '@/types/employment'
- describe('EmploymentHistory组件', () => {
- const mockHistory = [
- {
- orderId: 1,
- orderName: '数据标注员',
- companyName: '阿里巴巴集团',
- positionName: '数据标注员',
- joinDate: '2023-08-15',
- leaveDate: null,
- workStatus: WorkStatus.WORKING,
- salaryLevel: 4800
- },
- {
- orderId: 2,
- orderName: '内容审核员',
- companyName: '腾讯科技',
- positionName: '内容审核员',
- joinDate: '2023-03-10',
- leaveDate: '2023-07-31',
- workStatus: WorkStatus.RESIGNED,
- salaryLevel: 4500
- },
- {
- orderId: 3,
- orderName: '数据录入员',
- companyName: '字节跳动',
- positionName: '数据录入员',
- joinDate: '2022-09-01',
- leaveDate: '2023-02-28',
- workStatus: WorkStatus.RESIGNED,
- salaryLevel: 4200
- }
- ]
- it('应该渲染就业历史列表', () => {
- render(<EmploymentHistory history={mockHistory} loading={false} />)
- expect(screen.getByText('就业历史')).toBeInTheDocument()
- expect(screen.getByText('阿里巴巴集团')).toBeInTheDocument()
- expect(screen.getByText('腾讯科技')).toBeInTheDocument()
- expect(screen.getByText('字节跳动')).toBeInTheDocument()
- })
- it('应该显示加载状态', () => {
- render(<EmploymentHistory history={[]} loading={true} />)
- expect(screen.getByText('加载中...')).toBeInTheDocument()
- })
- it('应该显示无数据状态', () => {
- render(<EmploymentHistory history={[]} loading={false} />)
- expect(screen.getByText('暂无就业历史')).toBeInTheDocument()
- })
- it('应该显示时间范围信息', () => {
- render(<EmploymentHistory history={mockHistory} loading={false} />)
- expect(screen.getByText(/2023-08-15 至今/)).toBeInTheDocument()
- expect(screen.getByText(/2023-03-10 至 2023-07-31/)).toBeInTheDocument()
- })
- it('应该显示岗位名称', () => {
- render(<EmploymentHistory history={mockHistory} loading={false} />)
- expect(screen.getByText('数据标注员')).toBeInTheDocument()
- expect(screen.getByText('内容审核员')).toBeInTheDocument()
- expect(screen.getByText('数据录入员')).toBeInTheDocument()
- })
- })
|