import { render } from '@testing-library/react';
import { describe, it, expect } from 'vitest';
import { BenchmarkTable } from '../BenchmarkTable';

describe('BenchmarkTable', () => {
  it('renders all column headers', () => {
    const { getByText } = render(<BenchmarkTable />);

    expect(getByText('LLMHosts Local')).toBeTruthy();
    expect(getByText('LLMHosts + Cloud')).toBeTruthy();
    expect(getByText('RunPod')).toBeTruthy();
    expect(getByText('Together.ai')).toBeTruthy();
  });

  it('shows $0 cost for LLMHosts Local', () => {
    const { getAllByText } = render(<BenchmarkTable />);

    const zeroCost = getAllByText('$0');
    expect(zeroCost.length).toBeGreaterThanOrEqual(1);
  });

  it('shows check for LLMHosts and X for RunPod on data-stays-local row', () => {
    const { container } = render(<BenchmarkTable />);

    const rows = container.querySelectorAll('tbody tr');
    // "Data stays local" is the third row (index 2)
    const dataLocalRow = rows[2];
    const cells = dataLocalRow.querySelectorAll('td');

    // cells[0] = label, cells[1] = LLMHosts Local (check), cells[3] = RunPod (x)
    const localCheck = cells[1].querySelector('[aria-label="Yes"]');
    expect(localCheck).toBeTruthy();

    const runpodX = cells[3].querySelector('[aria-label="No"]');
    expect(runpodX).toBeTruthy();
  });

  it('renders the pricing footnote', () => {
    const { getByText } = render(<BenchmarkTable />);

    expect(
      getByText(/Rates based on public pricing as of Feb 2026/),
    ).toBeTruthy();
  });

  it('renders all row labels', () => {
    const { getByText } = render(<BenchmarkTable />);

    expect(getByText('Cost per 1M tokens')).toBeTruthy();
    expect(getByText('Setup time')).toBeTruthy();
    expect(getByText('Data stays local')).toBeTruthy();
    expect(getByText('Automatic failover')).toBeTruthy();
    expect(getByText('OpenAI-compatible')).toBeTruthy();
    expect(getByText('Free tier')).toBeTruthy();
  });
});
