import React from 'react'; import { mount } from 'enzyme'; /* eslint-disable import/no-unresolved */ import Form from '../../form'; import Input from '..'; import focusTest from '../../../tests/shared/focusTest'; import calculateNodeHeight, { calculateNodeStyling } from '../calculateNodeHeight'; const { TextArea } = Input; describe('Input', () => { const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); afterEach(() => { errorSpy.mockReset(); }); afterAll(() => { errorSpy.mockRestore(); }); focusTest(Input); it('should support maxLength', () => { const wrapper = mount(); expect(wrapper).toMatchSnapshot(); }); it('select()', () => { const wrapper = mount(); wrapper.instance().select(); }); describe('focus trigger warning', () => { it('not trigger', () => { const wrapper = mount(); wrapper .find('input') .instance() .focus(); wrapper.setProps({ suffix: 'light', }); expect(errorSpy).not.toBeCalled(); }); it('trigger warning', () => { const wrapper = mount(); wrapper .find('input') .instance() .focus(); wrapper.setProps({ suffix: 'light', }); expect(errorSpy).toBeCalledWith( 'Warning: [antd: Input] When Input is focused, dynamic add or remove prefix / suffix will make it lose focus caused by dom structure change. Read more: https://ant.design/components/input/#FAQ', ); }); }); }); focusTest(TextArea); describe('TextArea', () => { beforeAll(() => { jest.useFakeTimers(); }); afterAll(() => { jest.useRealTimers(); }); it('should auto calculate height according to content length', () => { const wrapper = mount(