Skip to content

Commit

Permalink
test: press enter to search
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed May 26, 2018
1 parent 12d0aed commit ac4a908
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions components/input/__tests__/Search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,14 @@ describe('Input.Search', () => {
expect(onSearch).toHaveBeenCalledTimes(1);
expect(onSearch).toBeCalledWith('search text');
});

it('should trigger onSearch when press enter', () => {
const onSearch = jest.fn();
const wrapper = mount(
<Search defaultValue="search text" onSearch={onSearch} />
);
wrapper.find('input').simulate('keydown', { key: 'Enter', keyCode: 13 });
expect(onSearch).toHaveBeenCalledTimes(1);
expect(onSearch).toBeCalledWith('search text');
});
});

0 comments on commit ac4a908

Please sign in to comment.