forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Checkbox Group disabled status (ant-design#7266)
- Loading branch information
xuwensheng
committed
Aug 24, 2017
1 parent
640fcc5
commit 3ad573d
Showing
5 changed files
with
80 additions
and
40 deletions.
There are no files selected for viewing
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
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,23 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Checkbox from '..'; | ||
|
||
describe('Checkbox', () => { | ||
it('responses hover events', () => { | ||
const onMouseEnter = jest.fn(); | ||
const onMouseLeave = jest.fn(); | ||
|
||
const wrapper = shallow( | ||
<Checkbox | ||
onMouseEnter={onMouseEnter} | ||
onMouseLeave={onMouseLeave} | ||
/> | ||
); | ||
|
||
wrapper.simulate('mouseenter'); | ||
expect(onMouseEnter).toHaveBeenCalled(); | ||
|
||
wrapper.simulate('mouseleave'); | ||
expect(onMouseLeave).toHaveBeenCalled(); | ||
}); | ||
}); |
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,54 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import Checkbox from '../index'; | ||
|
||
describe('CheckboxGroup', () => { | ||
it('should work basically', () => { | ||
const onChange = jest.fn(); | ||
const wrapper = mount( | ||
<Checkbox.Group options={['Apple', 'Pear', 'Orange']} onChange={onChange} /> | ||
); | ||
wrapper.find('.ant-checkbox-input').at(0).simulate('change'); | ||
expect(onChange).toBeCalledWith(['Apple']); | ||
wrapper.find('.ant-checkbox-input').at(1).simulate('change'); | ||
expect(onChange).toBeCalledWith(['Apple', 'Pear']); | ||
wrapper.find('.ant-checkbox-input').at(2).simulate('change'); | ||
expect(onChange).toBeCalledWith(['Apple', 'Pear', 'Orange']); | ||
wrapper.find('.ant-checkbox-input').at(1).simulate('change'); | ||
expect(onChange).toBeCalledWith(['Apple', 'Orange']); | ||
}); | ||
|
||
it('does not trigger onChange callback of both Checkbox and CheckboxGroup when CheckboxGroup is disabled', () => { | ||
const onChangeGroup = jest.fn(); | ||
|
||
const options = [ | ||
{ label: 'Apple', value: 'Apple' }, | ||
{ label: 'Pear', value: 'Pear' }, | ||
]; | ||
|
||
const groupWrapper = mount( | ||
<Checkbox.Group options={options} onChange={onChangeGroup} disabled /> | ||
); | ||
groupWrapper.find('.ant-checkbox-input').at(0).simulate('change'); | ||
expect(onChangeGroup).not.toBeCalled(); | ||
groupWrapper.find('.ant-checkbox-input').at(1).simulate('change'); | ||
expect(onChangeGroup).not.toBeCalled(); | ||
}); | ||
|
||
it('does not prevent onChange callback from Checkbox when CheckboxGroup is not disabled', () => { | ||
const onChangeGroup = jest.fn(); | ||
|
||
const options = [ | ||
{ label: 'Apple', value: 'Apple' }, | ||
{ label: 'Orange', value: 'Orange', disabled: true }, | ||
]; | ||
|
||
const groupWrapper = mount( | ||
<Checkbox.Group options={options} onChange={onChangeGroup} /> | ||
); | ||
groupWrapper.find('.ant-checkbox-input').at(0).simulate('change'); | ||
expect(onChangeGroup).toBeCalledWith(['Apple']); | ||
groupWrapper.find('.ant-checkbox-input').at(1).simulate('change'); | ||
expect(onChangeGroup).toBeCalledWith(['Apple']); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.