-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
26258af
commit bd6ddb9
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Added | ||
--- | ||
|
||
unit test cases for EntityHeader component ([#11222](https://github.com/linode/manager/pull/11222)) |
40 changes: 40 additions & 0 deletions
40
packages/manager/src/components/EntityHeader/EntityHeader.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
|
||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
|
||
import { EntityHeader } from './EntityHeader'; | ||
|
||
import { HeaderProps } from './EntityHeader'; | ||
|
||
const mockText = 'Hello world'; | ||
|
||
const defaultProps: HeaderProps = { | ||
title: mockText, | ||
}; | ||
|
||
describe('EntityHeader', () => { | ||
it('should render title with variant when isSummaryView is True', () => { | ||
const { getByRole } = renderWithTheme( | ||
<EntityHeader variant="h2" isSummaryView {...defaultProps} /> | ||
); | ||
const heading = getByRole('heading', { level: 2 }); | ||
expect(heading).toBeInTheDocument(); | ||
expect(heading).toHaveTextContent(mockText); | ||
}); | ||
|
||
it('should not render title when isSummaryView is False', () => { | ||
const { queryByText } = renderWithTheme( | ||
<EntityHeader isSummaryView={false} {...defaultProps} /> | ||
); | ||
expect(queryByText(mockText)).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render children if provided', () => { | ||
const { getByText } = renderWithTheme( | ||
<EntityHeader {...defaultProps}> | ||
<div>Child items can go here!</div> | ||
</EntityHeader> | ||
); | ||
expect(getByText('Child items can go here!')).toBeInTheDocument(); | ||
}); | ||
}); |