Skip to content

Commit 33c168b

Browse files
committed
add tests
1 parent 705bf30 commit 33c168b

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Matches the snapshot 1`] = `
4+
<DocumentFragment>
5+
<div
6+
class="pf-v6-c-compass__main-footer"
7+
>
8+
Custom children content
9+
</div>
10+
</DocumentFragment>
11+
`;

0 commit comments

Comments
 (0)