import { render, screen } from '@testing-library/react';
import { CompassMainFooter } from '../CompassMainFooter';
import styles from '@patternfly/react-styles/css/components/Compass/compass';
test('Renders without children', () => {
render(
);
expect(screen.getByTestId('test-main-footer').firstChild).toBeVisible();
});
test('Renders with children', () => {
render(Custom content);
expect(screen.getByText('Custom content')).toBeVisible();
});
test('Renders with custom class name when className prop is provided', () => {
render(Test);
expect(screen.getByText('Test')).toHaveClass('custom-class');
});
test(`Renders with default ${styles.compassMainFooter} class`, () => {
render(Test);
expect(screen.getByText('Test')).toHaveClass(styles.compassMainFooter);
});
test(`Renders with pf-m-expanded class by default`, () => {
render(Test);
expect(screen.getByText('Test')).toHaveClass('pf-m-expanded');
});
test(`Renders with pf-m-expanded class when isExpanded is true`, () => {
render(Test);
expect(screen.getByText('Test')).toHaveClass('pf-m-expanded');
});
test(`Renders without pf-m-expanded class when isExpanded is false`, () => {
render(Test);
expect(screen.getByText('Test')).not.toHaveClass('pf-m-expanded');
});
test('Renders with additional props spread to the component', () => {
render(Test);
expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
});
test('Matches the snapshot', () => {
const { asFragment } = render(Custom children content);
expect(asFragment()).toMatchSnapshot();
});