|
| 1 | +import { render, screen } from '@testing-library/react'; |
| 2 | +import { CompassMainFooter } from '../CompassMainFooter'; |
| 3 | +import styles from '@patternfly/react-styles/css/components/Compass/compass'; |
| 4 | + |
| 5 | +test('Renders without children', () => { |
| 6 | + render( |
| 7 | + <div data-testid="test-main-footer"> |
| 8 | + <CompassMainFooter /> |
| 9 | + </div> |
| 10 | + ); |
| 11 | + expect(screen.getByTestId('test-main-footer').firstChild).toBeVisible(); |
| 12 | +}); |
| 13 | + |
| 14 | +test('Renders with children', () => { |
| 15 | + render(<CompassMainFooter>Custom content</CompassMainFooter>); |
| 16 | + expect(screen.getByText('Custom content')).toBeVisible(); |
| 17 | +}); |
| 18 | + |
| 19 | +test('Renders with custom class name when className prop is provided', () => { |
| 20 | + render(<CompassMainFooter className="custom-class">Test</CompassMainFooter>); |
| 21 | + expect(screen.getByText('Test')).toHaveClass('custom-class'); |
| 22 | +}); |
| 23 | + |
| 24 | +test(`Renders with default ${styles.compassMainFooter} class`, () => { |
| 25 | + render(<CompassMainFooter>Test</CompassMainFooter>); |
| 26 | + expect(screen.getByText('Test')).toHaveClass(styles.compassMainFooter); |
| 27 | +}); |
| 28 | + |
| 29 | +test('Renders with additional props spread to the component', () => { |
| 30 | + render(<CompassMainFooter aria-label="Test label">Test</CompassMainFooter>); |
| 31 | + expect(screen.getByText('Test')).toHaveAccessibleName('Test label'); |
| 32 | +}); |
| 33 | + |
| 34 | +test('Matches the snapshot', () => { |
| 35 | + const { asFragment } = render(<CompassMainFooter>Custom children content</CompassMainFooter>); |
| 36 | + expect(asFragment()).toMatchSnapshot(); |
| 37 | +}); |
0 commit comments