/**
 * SalaryRecordItem组件测试
 */
import React from 'react'
import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom'
import { SalaryRecordItem } from '@/components/SalaryRecordItem'

describe('SalaryRecordItem组件', () => {
  const mockRecord = {
    orderId: 1,
    orderName: '数据标注员',
    companyName: '测试科技有限公司',
    salaryAmount: 4800,
    joinDate: '2023-08-15',
    month: '2023-11'
  }

  it('应该渲染薪资记录项', () => {
    render(<SalaryRecordItem record={mockRecord} />)

    expect(screen.getByText('2023年11月')).toBeInTheDocument()
    expect(screen.getByText('¥4,800')).toBeInTheDocument()
  })

  it('应该显示企业和岗位信息', () => {
    render(<SalaryRecordItem record={mockRecord} />)

    expect(screen.getByText(/测试科技有限公司/)).toBeInTheDocument()
    expect(screen.getByText(/数据标注员/)).toBeInTheDocument()
  })

  it('应该处理空企业名称', () => {
    const recordWithoutCompany = { ...mockRecord, companyName: null, orderName: null }
    render(<SalaryRecordItem record={recordWithoutCompany} />)

    expect(screen.getByText(/未知企业/)).toBeInTheDocument()
    expect(screen.getByText(/未知岗位/)).toBeInTheDocument()
  })

  it('应该格式化薪资金额', () => {
    const largeSalary = { ...mockRecord, salaryAmount: 10000 }
    render(<SalaryRecordItem record={largeSalary} />)

    expect(screen.getByText('¥10,000')).toBeInTheDocument()
  })
})
