Skip to content

Commit bd6ddb9

Browse files
test: [M3-8550] - Add unit tests for EntityHeader component (#11222)
* test: [M3-8550] - Add unit tests for EntityHeader component * Added changeset: unit test cases for EntityHeader component
1 parent 26258af commit bd6ddb9

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Added
3+
---
4+
5+
unit test cases for EntityHeader component ([#11222](https://github.com/linode/manager/pull/11222))
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
3+
import { renderWithTheme } from 'src/utilities/testHelpers';
4+
5+
import { EntityHeader } from './EntityHeader';
6+
7+
import { HeaderProps } from './EntityHeader';
8+
9+
const mockText = 'Hello world';
10+
11+
const defaultProps: HeaderProps = {
12+
title: mockText,
13+
};
14+
15+
describe('EntityHeader', () => {
16+
it('should render title with variant when isSummaryView is True', () => {
17+
const { getByRole } = renderWithTheme(
18+
<EntityHeader variant="h2" isSummaryView {...defaultProps} />
19+
);
20+
const heading = getByRole('heading', { level: 2 });
21+
expect(heading).toBeInTheDocument();
22+
expect(heading).toHaveTextContent(mockText);
23+
});
24+
25+
it('should not render title when isSummaryView is False', () => {
26+
const { queryByText } = renderWithTheme(
27+
<EntityHeader isSummaryView={false} {...defaultProps} />
28+
);
29+
expect(queryByText(mockText)).not.toBeInTheDocument();
30+
});
31+
32+
it('should render children if provided', () => {
33+
const { getByText } = renderWithTheme(
34+
<EntityHeader {...defaultProps}>
35+
<div>Child items can go here!</div>
36+
</EntityHeader>
37+
);
38+
expect(getByText('Child items can go here!')).toBeInTheDocument();
39+
});
40+
});

0 commit comments

Comments
 (0)