Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Sidenav): fix missing highlight on selected dropdown items (#2216)
- Loading branch information
1 parent
c4737d5
commit 8f79d4a
Showing
3 changed files
with
52 additions
and
10 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
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 |
---|---|---|
@@ -1,15 +1,53 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import Sidenav from '../index'; | ||
import { getDOMNode, getStyle } from '@test/testUtils'; | ||
import { getDOMNode, getStyle, getDefaultPalette } from '@test/testUtils'; | ||
import Nav from '../../Nav'; | ||
import Dropdown from '../../Dropdown'; | ||
import Sidenav from '../Sidenav'; | ||
|
||
import '../styles/index.less'; | ||
|
||
describe('Sidenav styles', () => { | ||
it('Should render the correct styles', () => { | ||
const instanceRef = React.createRef(); | ||
render(<Sidenav ref={instanceRef} expanded={false} />); | ||
const dom = getDOMNode(instanceRef.current); | ||
assert.equal(getStyle(dom, 'width'), '56px', 'Sidenav width'); | ||
context('Default', () => { | ||
it('Should render the correct styles', () => { | ||
const instanceRef = React.createRef(); | ||
render(<Sidenav ref={instanceRef} expanded={false} />); | ||
const dom = getDOMNode(instanceRef.current); | ||
assert.equal(getStyle(dom, 'width'), '56px', 'Sidenav width'); | ||
}); | ||
|
||
it('Should highlight selected dropdown item', () => { | ||
const { getByTestId } = render( | ||
<Sidenav> | ||
<Nav> | ||
<Dropdown title="Dropdown"> | ||
<Dropdown.Item data-testid="item" active> | ||
Dropdown Item | ||
</Dropdown.Item> | ||
</Dropdown> | ||
</Nav> | ||
</Sidenav> | ||
); | ||
|
||
expect(getByTestId('item')).to.have.style('color', getDefaultPalette('H700')); | ||
}); | ||
}); | ||
|
||
context('Subtle', () => { | ||
it('Should highlight selected dropdown item', () => { | ||
const { getByTestId } = render( | ||
<Sidenav appearance="subtle"> | ||
<Nav> | ||
<Dropdown title="Dropdown"> | ||
<Dropdown.Item data-testid="item" active> | ||
Dropdown Item | ||
</Dropdown.Item> | ||
</Dropdown> | ||
</Nav> | ||
</Sidenav> | ||
); | ||
|
||
expect(getByTestId('item')).to.have.style('color', getDefaultPalette('H700')); | ||
}); | ||
}); | ||
}); |
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
8f79d4a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
rsuite-nextjs – ./docs
rsuite.vercel.app
rsuitejs.com
rsuite-nextjs-git-main-rsuite.vercel.app
rsuite-nextjs-rsuite.vercel.app
next.rsuitejs.com