diff --git a/src/checkbox/CheckboxGroup.tsx b/src/checkbox/CheckboxGroup.tsx index a80f3608ff..9427761f93 100644 --- a/src/checkbox/CheckboxGroup.tsx +++ b/src/checkbox/CheckboxGroup.tsx @@ -152,21 +152,17 @@ const CheckboxGroup = (props: {useOptions ? options.map((v: any, index) => { - const type = typeof v; - switch (type) { - case 'string': { - const vs = v as string; + switch (typeof v) { + case 'string': return ( - + {v} ); - } case 'number': { - const vs = v as number; return ( - - {v} + + {String(v)} ); } diff --git a/src/checkbox/__tests__/checkbox.test.tsx b/src/checkbox/__tests__/checkbox.test.tsx index 9a2a7b2d14..c73dc64044 100644 --- a/src/checkbox/__tests__/checkbox.test.tsx +++ b/src/checkbox/__tests__/checkbox.test.tsx @@ -76,6 +76,7 @@ describe('CheckboxGroup', () => { { value: '广州', label: '广州', disabled: true }, { value: '北京', label: '北京', name: '北京' }, 1, + 0, '重庆', { label: '全选', checkAll: true }, ]} @@ -83,6 +84,9 @@ describe('CheckboxGroup', () => { ); fireEvent.click(container.firstChild.lastChild); expect(container.firstChild.firstChild).toHaveClass('t-is-checked'); + const options = container.firstChild.childNodes; + // 0 is rendered as string '0' + expect(options.item(4).textContent).toBe('0'); }); test('value is string', () => {