Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ToggleButton): remove
role="button"
from label (#6204)
- Loading branch information
Showing
4 changed files
with
41 additions
and
28 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { expect } from 'chai'; | ||
|
||
import ToggleButton from '../src/ToggleButton'; | ||
|
||
describe('ToggleButton', () => { | ||
it('should forward refs to the label', () => { | ||
const ref = React.createRef<HTMLLabelElement>(); | ||
render( | ||
<ToggleButton id="id" ref={ref} value={1}> | ||
Option | ||
</ToggleButton>, | ||
); | ||
|
||
ref.current!.tagName.should.equal('LABEL'); | ||
}); | ||
|
||
it('should add an inputRef', () => { | ||
const ref = React.createRef<HTMLInputElement>(); | ||
render( | ||
<ToggleButton id="id" inputRef={ref} value={1}> | ||
Option | ||
</ToggleButton>, | ||
); | ||
|
||
ref.current!.tagName.should.equal('INPUT'); | ||
}); | ||
|
||
it('should not have a role on the label button', () => { | ||
const { getByText } = render( | ||
<ToggleButton id="id" value={1}> | ||
Option | ||
</ToggleButton>, | ||
); | ||
|
||
expect(getByText('Option').getAttribute('role')).to.not.exist; | ||
}); | ||
}); |