/**
 * PriorityBadge Component Tests
 */

import { render, screen } from '@testing-library/react';
import { PriorityBadge } from '@/features/issues/components/PriorityBadge';
import type { IssuePriority } from '@/features/issues/types';

describe('PriorityBadge', () => {
  const priorities: IssuePriority[] = ['high', 'medium', 'low'];

  it.each(priorities)('renders %s priority correctly', (priority) => {
    render(<PriorityBadge priority={priority} />);

    // The priority should be displayed as capitalized
    const capitalizedPriority = priority.charAt(0).toUpperCase() + priority.slice(1);
    expect(screen.getByText(capitalizedPriority)).toBeInTheDocument();
  });

  it('applies custom className', () => {
    render(<PriorityBadge priority="high" className="custom-class" />);

    const badge = screen.getByText('High');
    expect(badge).toHaveClass('custom-class');
  });

  it('renders critical priority', () => {
    render(<PriorityBadge priority="critical" />);

    expect(screen.getByText('Critical')).toBeInTheDocument();
  });

  it('falls back to medium config for unknown priority', () => {
    // @ts-expect-error - Testing unknown priority value
    render(<PriorityBadge priority="unknown-priority" />);

    // Should fall back to medium config
    expect(screen.getByText('Medium')).toBeInTheDocument();
  });
});
