All files / src/components/admin/monitoring CategoryBadge.test.tsx

0% Statements 0/35
100% Branches 0/0
0% Functions 0/1
0% Lines 0/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                                       
import React from 'react';
import { render, screen } from '@testing-library/react';
import { CategoryBadge } from './CategoryBadge';

describe('CategoryBadge', () => {
  it('renders category text', () => {
    render(<CategoryBadge category="API" />);
    expect(screen.getByText('API')).toBeInTheDocument();
  });

  it('has correct test id', () => {
    render(<CategoryBadge category="DATABASE" />);
    expect(screen.getByTestId('category-badge')).toBeInTheDocument();
  });

  it('applies custom className', () => {
    render(<CategoryBadge category="AUTH" className="custom-class" />);
    expect(screen.getByTestId('category-badge')).toHaveClass('custom-class');
  });

  it('returns null for null category', () => {
    const { container } = render(<CategoryBadge category={null} />);
    expect(container.firstChild).toBeNull();
  });

  it('returns null for undefined category', () => {
    const { container } = render(<CategoryBadge category={undefined} />);
    expect(container.firstChild).toBeNull();
  });

  it('renders empty string category as null', () => {
    const { container } = render(<CategoryBadge category="" />);
    expect(container.firstChild).toBeNull();
  });
});