import { spyElementPrototypes } from 'rc-util/lib/test/domHook'; import type { ChangeEventHandler, TextareaHTMLAttributes } from 'react'; import React, { useState } from 'react'; import Input from '..'; import focusTest from '../../../tests/shared/focusTest'; import type { RenderOptions } from '../../../tests/utils'; import { fireEvent, pureRender, render, triggerResize, waitFakeTimer } from '../../../tests/utils'; import type { TextAreaRef } from '../TextArea'; const { TextArea } = Input; focusTest(TextArea, { refFocus: true }); describe('TextArea', () => { const originalGetComputedStyle = window.getComputedStyle; beforeAll(() => { Object.defineProperty(window, 'getComputedStyle', { value: (node: Element) => ({ getPropertyValue: (prop: PropertyKey) => prop === 'box-sizing' ? originalGetComputedStyle(node)[prop as unknown as number] || 'border-box' : originalGetComputedStyle(node)[prop as unknown as number], }), }); }); afterAll(() => { Object.defineProperty(window, 'getComputedStyle', { value: originalGetComputedStyle }); }); it('should auto calculate height according to content length', async () => { jest.useFakeTimers(); const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}); const ref = React.createRef(); const onInternalAutoSize = jest.fn(); const genTextArea = (props = {}) => (