Skip to content

Commit

Permalink
fix: fixes test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Micko committed Feb 28, 2019
1 parent 923a68d commit c1a27b7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/react-dropdown/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,3 +546,34 @@ it('Children provided trough items should be present', () => {
expect(children.prop('data-itemid')).toBe(131);
expect(children.length).toBe(1);
});

it('should clear the previous selected items', () => {
const wrapper = mount(
<Dropdown items={[{ id: 10, label: 'Hello world' }]} initialIsOpen={true}>
{({ getInputProps, clearSelection }) => (
<div>
<Input {...getInputProps()} />
<button onClick={clearSelection}>Reset</button>
</div>
)}
</Dropdown>
);

wrapper.find('ul li').simulate('click');

expect(
wrapper
.find('input')
.at(0)
.props().value
).toBe(10);

wrapper.find('button').simulate('click');

expect(
wrapper
.find('input')
.at(0)
.props().value
).toBe('');
});

0 comments on commit c1a27b7

Please sign in to comment.