You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
684 B

import React from 'react';
import { mount } from 'enzyme';
import Input from '..';
7 years ago
const { TextArea } = Input;
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
7 years ago
describe('TextArea', () => {
it('should auto calculate height according to content length', async () => {
const wrapper = mount(
7 years ago
<TextArea value="" readOnly autosize />
);
7 years ago
const mockFunc = jest.spyOn(wrapper.node, 'resizeTextarea');
wrapper.setProps({ value: '1111\n2222\n3333' });
await delay(0);
7 years ago
expect(mockFunc).toHaveBeenCalledTimes(1);
wrapper.setProps({ value: '1111' });
await delay(0);
7 years ago
expect(mockFunc).toHaveBeenCalledTimes(2);
});
});