Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed a11y property error message (#1673)
* Fixed a11y propery error message

* Dropdown compare custom props with attrs test
  • Loading branch information
z1m1n authored and TheSharpieOne committed Oct 18, 2019
1 parent daf343a commit 87d28b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Dropdown.js
Expand Up @@ -206,7 +206,7 @@ class Dropdown extends React.Component {
addonType,
tag,
...attrs
} = omit(this.props, ['toggle', 'disabled', 'inNavbar']);
} = omit(this.props, ['toggle', 'disabled', 'inNavbar', 'a11y']);

const Tag = tag || (nav ? 'li' : 'div');

Expand Down
16 changes: 16 additions & 0 deletions src/__tests__/Dropdown.spec.js
Expand Up @@ -68,6 +68,22 @@ describe('Dropdown', () => {
});

describe('handleProps', () => {
it('should not pass custom props to html attrs', () => {
const wrapper = mount(
<Dropdown inNavbar a11y isOpen={isOpen} toggle={toggle}>
<DropdownToggle>Toggle</DropdownToggle>
<DropdownMenu>
<DropdownItem>Test</DropdownItem>
</DropdownMenu>
</Dropdown>
);

expect(wrapper.find('.dropdown').prop('inNavbar')).toBe(undefined);
expect(wrapper.find('.dropdown').prop('toggle')).toBe(undefined);
expect(wrapper.find('.dropdown').prop('a11y')).toBe(undefined);
expect(wrapper.find('.dropdown').prop('isOpen')).toBe(undefined);
});

it('should be called on componentDidUpdate when isOpen changed', () => {
jest.spyOn(Dropdown.prototype, 'componentDidUpdate');
jest.spyOn(Dropdown.prototype, 'handleProps');
Expand Down

0 comments on commit 87d28b6

Please sign in to comment.