diff --git a/components/input/TextArea.tsx b/components/input/TextArea.tsx index 02c5624c77..eb12b0678e 100644 --- a/components/input/TextArea.tsx +++ b/components/input/TextArea.tsx @@ -110,6 +110,11 @@ export default class TextArea extends React.Component { expect(mockFunc).toHaveBeenCalledTimes(2); }); }); + +describe('As Form Control', () => { + it('should be reset when wrapped in form.getFieldDecorator without initialValue', async () => { + class Demo extends React.Component { + reset = () => { + this.props.form.resetFields(); + } + render() { + const { getFieldDecorator } = this.props.form; + return ( +
+ + {getFieldDecorator('input')()} + + + {getFieldDecorator('textarea')()} + + +
+ ); + } + } + const DemoForm = Form.create()(Demo); + const wrapper = mount(); + wrapper.find('input').simulate('change', { target: { value: '111' } }); + wrapper.find('textarea').simulate('change', { target: { value: '222' } }); + expect(wrapper.find('input').prop('value')).toBe('111'); + expect(wrapper.find('textarea').prop('value')).toBe('222'); + wrapper.find('button').simulate('click'); + expect(wrapper.find('input').prop('value')).toBe(''); + expect(wrapper.find('textarea').prop('value')).toBe(''); + }); +});