import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { Badge } from '../Badge';
test('Renders without children', () => {
render(
);
expect(screen.getByTestId('badge').firstChild).toBeVisible();
});
test('Renders children', () => {
render(Test);
expect(screen.getByText('Test')).toBeVisible();
});
test('Renders with class name pf-v5-c-badge', () => {
render(Test);
expect(screen.getByText('Test')).toHaveClass('pf-v5-c-badge');
});
test('Renders with class name pf-m-unread by default', () => {
render(Test);
expect(screen.getByText('Test')).toHaveClass('pf-m-unread');
});
test('Renders with class name pf-m-read when isRead prop is true', () => {
render(Test);
expect(screen.getByText('Test')).toHaveClass('pf-m-read');
});
test('Does not render pf-v5-screen-reader class by default', () => {
render(Test);
expect(screen.getByText('Test')).not.toContainHTML('');
});
test('Renders screenReaderText passed via prop', () => {
render(Test);
expect(screen.getByText('Custom screen reader text')).toBeInTheDocument();
});
test('Renders with custom class name when className prop is provided', () => {
render(Test);
expect(screen.getByText('Test')).toHaveClass('custom-class');
});
test('Renders with inherited element props spread to the component', () => {
render(Test);
expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
});
test('Matches the snapshot', () => {
const { asFragment } = render(Test);
expect(asFragment()).toMatchSnapshot();
});