Skip to content

Commit

Permalink
add test case for checkbox handling context update
Browse files Browse the repository at this point in the history
  • Loading branch information
morenyang committed Jan 30, 2020
1 parent c4f27a4 commit e9baa29
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions components/checkbox/__tests__/group.test.js
@@ -1,5 +1,6 @@
import React from 'react';
import { mount, render } from 'enzyme';
import Collapse from '../../collapse';
import Checkbox from '../index';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
Expand Down Expand Up @@ -181,4 +182,44 @@ describe('CheckboxGroup', () => {
.simulate('change');
expect(onChange).toHaveBeenCalledWith([1, 2]);
});

// https://github.com/ant-design/ant-design/issues/21134
it('should work when checkbox is wrapped by other components', () => {
const wrapper = mount(
<Checkbox.Group>
<Collapse bordered={false}>
<Collapse.Panel header="test panel">
<div>
<Checkbox value="1">item</Checkbox>
</div>
</Collapse.Panel>
</Collapse>
</Checkbox.Group>,
);
wrapper
.find('.ant-collapse-item')
.at(0)
.find('.ant-collapse-header')
.simulate('click');
wrapper
.find('.ant-checkbox-input')
.at(0)
.simulate('change');
expect(
wrapper
.find(Checkbox.Group)
.at(0)
.state('value'),
).toEqual(['1']);
wrapper
.find('.ant-checkbox-input')
.at(0)
.simulate('change');
expect(
wrapper
.find(Checkbox.Group)
.at(0)
.state('value'),
).toEqual([]);
});
});

0 comments on commit e9baa29

Please sign in to comment.