import React from 'react'; import { mount } from 'enzyme'; import Input from '..'; import Form from '../../form'; import focusTest from '../../../tests/shared/focusTest'; const { TextArea } = Input; describe('Input', () => { focusTest(Input); it('should support maxLength', () => { const wrapper = mount( ); expect(wrapper).toMatchSnapshot(); }); }); focusTest(TextArea); describe('TextArea', () => { beforeAll(() => { jest.useFakeTimers(); }); afterAll(() => { jest.useRealTimers(); }); it('should auto calculate height according to content length', () => { const wrapper = mount( ); const mockFunc = jest.spyOn(wrapper.instance(), 'resizeTextarea'); wrapper.setProps({ value: '1111\n2222\n3333' }); jest.runAllTimers(); expect(mockFunc).toHaveBeenCalledTimes(1); wrapper.setProps({ value: '1111' }); jest.runAllTimers(); expect(mockFunc).toHaveBeenCalledTimes(2); }); it('should support disabled', () => { const wrapper = mount( ); expect(wrapper).toMatchSnapshot(); }); it('should support maxLength', () => { const wrapper = mount( ); expect(wrapper).toMatchSnapshot(); }); }); describe('As Form Control', () => { it('should be reset when wrapped in form.getFieldDecorator without initialValue', () => { class Demo extends React.Component { reset = () => { const { form } = this.props; form.resetFields(); } render() { const { form: { getFieldDecorator } } = this.props; return (