-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ClearAll): always display clearAll button, disabled when no filter (
- Loading branch information
Showing
3 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/react-instantsearch/src/components/ClearAll.enzyme.test.js
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,36 @@ | ||
|
||
/* eslint-env jest, jasmine */ | ||
|
||
// @TODO re-include this test in the normal .test.js | ||
// when React 15.4 is out: https://github.com/facebook/react/issues/7386 | ||
|
||
import React from 'react'; | ||
import {mount} from 'enzyme'; | ||
|
||
import ClearAll from './ClearAll.js'; | ||
|
||
describe('ClearAll', () => { | ||
it('is disabled when there is no filters', () => { | ||
const refine = jest.fn(); | ||
const wrapper = mount( | ||
<ClearAll refine={refine} items={[]}/> | ||
); | ||
|
||
const btn = wrapper.find('button'); | ||
expect(refine.mock.calls.length).toBe(0); | ||
btn.simulate('click'); | ||
expect(refine.mock.calls.length).toBe(0); | ||
}); | ||
|
||
it('is not disabled when there are filters', () => { | ||
const refine = jest.fn(); | ||
const wrapper = mount( | ||
<ClearAll refine={refine} items={[{value: 'test', label: 'test: test'}]}/> | ||
); | ||
|
||
const btn = wrapper.find('button'); | ||
expect(refine.mock.calls.length).toBe(0); | ||
btn.simulate('click'); | ||
expect(refine.mock.calls.length).toBe(1); | ||
}); | ||
}); |
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