Skip to content

Commit 02d8d1b

Browse files
committed
fix(*): correct Checkbox&Radio's display name
1 parent bf365d7 commit 02d8d1b

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/checkbox/with-context.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33

44
export default function withContext(Checkbox) {
55
return class WrappedComp extends React.Component {
6+
static displayName = 'Checkbox';
67
static contextTypes = {
78
onChange: PropTypes.func,
89
__group__: PropTypes.bool,

src/radio/with-context.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33

44
export default function withContext(Radio) {
55
return class WrappedComp extends React.Component {
6+
static displayName = 'Radio';
67
static contextTypes = {
78
onChange: PropTypes.func,
89
__group__: PropTypes.bool,

test/form/index-spec.js

+22
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import assert from 'power-assert';
66
import Input from '../../src/input';
77
import Field from '../../src/field';
88
import Select from '../../src/select';
9+
import Radio from '../../src/radio';
10+
import Checkbox from '../../src/checkbox';
911
import Form from '../../src/form/index';
1012

1113
const FormItem = Form.Item;
@@ -312,6 +314,26 @@ describe('form', () => {
312314
);
313315
assert(saveRef.calledOnce);
314316
});
317+
318+
it('should supoort defaultvalue', () => {
319+
const value = {
320+
'checkbox-1':true,
321+
'radio-1': true,
322+
};
323+
const wrapper = mount(
324+
<Form value={value}>
325+
<FormItem label="不支持购物车下单:">
326+
<Checkbox name="checkbox-1">(商品标签[6658])</Checkbox>
327+
</FormItem>
328+
<FormItem label="不支持购物车下单:">
329+
<Radio name="radio-1">(商品标签[6658])</Radio>
330+
</FormItem>
331+
</Form>
332+
);
333+
assert(wrapper.find('input#checkbox-1').props().checked);
334+
assert(wrapper.find('input#radio-1').props().checked);
335+
});
336+
315337
it('should supoort function children', () => {
316338
const wrapper = mount(
317339
<Form>

0 commit comments

Comments
 (0)