Skip to content

Commit a182f60

Browse files
committed
Address Eric's feedback
1 parent cd18b6d commit a182f60

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

packages/react-core/src/components/Page/__tests__/Page.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ describe('Page docked variant', () => {
529529
</Page>
530530
);
531531

532-
const footer = screen.getByText('Custom footer');
532+
const footer = screen.getByRole('contentinfo');
533533
expect(footer).toHaveClass(styles.pageFooter);
534534
expect(footer.parentElement).toHaveClass(styles.page);
535535
});

packages/react-core/src/components/Page/__tests__/PageFooter.test.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,22 @@ import { PageFooter } from '../PageFooter';
44

55
test('Renders children', () => {
66
render(<PageFooter>Footer content</PageFooter>);
7-
expect(screen.getByText('Footer content')).toBeVisible();
7+
expect(screen.getByRole('contentinfo')).toBeVisible();
8+
});
9+
10+
test('Renders without children', () => {
11+
render(<PageFooter data-testid="footer" />);
12+
expect(screen.getByTestId('footer')).toBeVisible();
813
});
914

1015
test(`Renders with class ${styles.pageFooter} by default`, () => {
1116
render(<PageFooter>Footer content</PageFooter>);
12-
expect(screen.getByText('Footer content')).toHaveClass(styles.pageFooter, { exact: true });
17+
expect(screen.getByRole('contentinfo')).toHaveClass(styles.pageFooter, { exact: true });
1318
});
1419

1520
test('Renders as a footer by default', () => {
1621
render(<PageFooter>Footer content</PageFooter>);
17-
expect(screen.getByText('Footer content').tagName).toBe('FOOTER');
22+
expect(screen.getByRole('contentinfo').tagName).toBe('FOOTER');
1823
});
1924

2025
test('Renders as a custom component when component is passed', () => {
@@ -24,10 +29,10 @@ test('Renders as a custom component when component is passed', () => {
2429

2530
test('Renders with custom classes when className is passed', () => {
2631
render(<PageFooter className="custom-class">Footer content</PageFooter>);
27-
expect(screen.getByText('Footer content')).toHaveClass('custom-class');
32+
expect(screen.getByRole('contentinfo')).toHaveClass('custom-class');
2833
});
2934

3035
test('Renders with spread props', () => {
3136
render(<PageFooter id="custom-id">Footer content</PageFooter>);
32-
expect(screen.getByText('Footer content')).toHaveAttribute('id', 'custom-id');
37+
expect(screen.getByRole('contentinfo')).toHaveAttribute('id', 'custom-id');
3338
});

0 commit comments

Comments
 (0)