import React from 'react';
import { render, screen } from '@testing-library/react';
import ApkTable from '../ApkTable';

describe('ApkTable', () => {
  const mockApks = [
    {
      name: 'ft_timeshift_0_42_57ef3a60d.apk',
      commit: '57ef3a60d',
      size: 15728640,
      modifiedAt: '2026-03-04T14:30:00.000Z',
      downloadUrl: '/api/download?project=FT&version=0_42&filename=ft_timeshift_0_42_57ef3a60d.apk',
    },
  ];

  it('should render table with correct columns', () => {
    render(<ApkTable apks={mockApks} />);

    expect(screen.getByText('Commit ID')).toBeInTheDocument();
    expect(screen.getByText('文件大小')).toBeInTheDocument();
    expect(screen.getByText('创建时间')).toBeInTheDocument();
  });

  it('should render APK data correctly', () => {
    render(<ApkTable apks={mockApks} />);

    expect(screen.getByText('57ef3a60d')).toBeInTheDocument();
    expect(screen.getByText('15.00 MB')).toBeInTheDocument();
    expect(screen.getByText('2026-03-04 22:30')).toBeInTheDocument();
    expect(screen.getByText('下载')).toBeInTheDocument();
  });

  it('should show empty state when no APKs', () => {
    render(<ApkTable apks={[]} />);

    expect(screen.getByText('暂无 APK 文件')).toBeInTheDocument();
  });
});
