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

describe('StatusBadge', () => {
  it('renders "Confirmed" label for confirmed status', () => {
    render(<StatusBadge status="confirmed" />);
    expect(screen.getByText('Confirmed')).toBeInTheDocument();
  });

  it('renders "Pending" label for pending status', () => {
    render(<StatusBadge status="pending" />);
    expect(screen.getByText('Pending')).toBeInTheDocument();
  });

  it('renders "Cancelled" label for cancelled status', () => {
    render(<StatusBadge status="cancelled" />);
    expect(screen.getByText('Cancelled')).toBeInTheDocument();
  });

  it('falls back to raw status string for unknown status', () => {
    render(<StatusBadge status="unknown-state" />);
    expect(screen.getByText('unknown-state')).toBeInTheDocument();
  });

  it('sets aria-label with status text', () => {
    render(<StatusBadge status="confirmed" />);
    expect(screen.getByRole('generic', { name: /status: confirmed/i })).toBeInTheDocument();
  });

  it('applies size modifier class', () => {
    const { container } = render(<StatusBadge status="pending" size="sm" />);
    const badge = container.firstChild;
    expect(badge.className).toMatch(/sm/);
  });
});
