-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(HeaderSideNavItems): add tests (#13303)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c74db90
commit 94ebea3
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/react/src/components/UIShell/__tests__/HeaderSideNavItems-test.js
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 @@ | ||
/** | ||
* Copyright IBM Corp. 2022 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import HeaderSideNavItems from '../HeaderSideNavItems'; | ||
import { render, screen } from '@testing-library/react'; | ||
import HeaderMenuItem from '../HeaderMenuItem'; | ||
|
||
describe('HeaderSideNavItems', () => { | ||
describe('renders as expected - Component API', () => { | ||
it('should render children as expected', () => { | ||
render( | ||
<HeaderSideNavItems> | ||
<HeaderMenuItem href="#">Link 1</HeaderMenuItem> | ||
<HeaderMenuItem href="#">Link 2</HeaderMenuItem> | ||
</HeaderSideNavItems> | ||
); | ||
|
||
expect(screen.getAllByRole('listitem')).toHaveLength(2); | ||
}); | ||
|
||
it('should support a custom `className` prop on the outermost element', () => { | ||
const { container } = render( | ||
<HeaderSideNavItems className="custom-class" /> | ||
); | ||
|
||
expect(container.firstChild).toHaveClass('custom-class'); | ||
}); | ||
|
||
it('should respect hasDivider prop', () => { | ||
const { container } = render(<HeaderSideNavItems hasDivider />); | ||
|
||
expect(container.firstChild).toHaveClass('cds--side-nav__header-divider'); | ||
}); | ||
}); | ||
}); |