From 31d9d74588d451a448096a30f13b4ba267161d8f Mon Sep 17 00:00:00 2001 From: Vaillant Samuel Date: Thu, 15 Feb 2018 19:46:21 +0100 Subject: [PATCH] fix(SearchBox): avoid to bind click on reset button --- packages/react-instantsearch/src/components/SearchBox.js | 7 +------ .../react-instantsearch/src/components/SearchBox.test.js | 8 ++++---- .../src/components/__snapshots__/Menu.test.js.snap | 3 --- .../components/__snapshots__/RefinementList.test.js.snap | 3 --- .../src/components/__snapshots__/SearchBox.test.js.snap | 9 --------- 5 files changed, 5 insertions(+), 25 deletions(-) diff --git a/packages/react-instantsearch/src/components/SearchBox.js b/packages/react-instantsearch/src/components/SearchBox.js index 214b9c8124..639dbb9f31 100644 --- a/packages/react-instantsearch/src/components/SearchBox.js +++ b/packages/react-instantsearch/src/components/SearchBox.js @@ -291,12 +291,7 @@ class SearchBox extends Component { > {submitComponent} - diff --git a/packages/react-instantsearch/src/components/SearchBox.test.js b/packages/react-instantsearch/src/components/SearchBox.test.js index f6108765f6..617e23657b 100644 --- a/packages/react-instantsearch/src/components/SearchBox.test.js +++ b/packages/react-instantsearch/src/components/SearchBox.test.js @@ -252,7 +252,7 @@ describe('SearchBox', () => { instanceWithLoadingIndicator.unmount(); }); - it('expect to clear the query when the reset button is click with searchAsYouType=true', () => { + it('expect to clear the query when the form is reset with searchAsYouType=true', () => { const refine = jest.fn(); const wrapper = shallow( @@ -262,13 +262,13 @@ describe('SearchBox', () => { // Simulate the ref wrapper.instance().input = { focus: jest.fn() }; - wrapper.find('button[type="reset"]').simulate('click'); + wrapper.find('form').simulate('reset'); expect(refine).toHaveBeenCalledWith(''); expect(wrapper.instance().input.focus).toHaveBeenCalled(); }); - it('expect to clear the query when the reset button is click with searchAsYouType=false', () => { + it('expect to clear the query when the form is reset with searchAsYouType=false', () => { const refine = jest.fn(); const wrapper = shallow( @@ -281,7 +281,7 @@ describe('SearchBox', () => { // Simulate change event wrapper.setState({ query: 'Hello' }); - wrapper.find('button[type="reset"]').simulate('click'); + wrapper.find('form').simulate('reset'); expect(refine).toHaveBeenCalledWith(''); expect(wrapper.instance().input.focus).toHaveBeenCalled(); diff --git a/packages/react-instantsearch/src/components/__snapshots__/Menu.test.js.snap b/packages/react-instantsearch/src/components/__snapshots__/Menu.test.js.snap index d352f2dd76..9caecf9ef3 100644 --- a/packages/react-instantsearch/src/components/__snapshots__/Menu.test.js.snap +++ b/packages/react-instantsearch/src/components/__snapshots__/Menu.test.js.snap @@ -80,7 +80,6 @@ exports[`Menu Menu with search inside items but no search results 1`] = `