mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 21:19:37 +08:00
test: update cases for TextArea
This commit is contained in:
parent
b4146854d6
commit
9867e6f4cc
@ -1,7 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
import { mount } from 'enzyme';
|
||||
|
||||
/* eslint-disable import/no-unresolved */
|
||||
import Form from '../../form';
|
||||
import Input from '..';
|
||||
@ -118,6 +116,28 @@ describe('TextArea', () => {
|
||||
overflowY: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it('when prop autosize changed, updateResizeObserverHook should be called', () => {
|
||||
const wrapper = mount(<TextArea autosize />);
|
||||
wrapper.setProps({ autosize: false });
|
||||
expect(wrapper.instance().resizeObserver).toBe(null);
|
||||
});
|
||||
|
||||
it('when prop value not in this.props, resizeTextarea should be called', () => {
|
||||
const wrapper = mount(<TextArea />);
|
||||
const resizeTextarea = jest.spyOn(wrapper.instance(), 'resizeTextarea');
|
||||
wrapper.find('textarea').simulate('change', 'test');
|
||||
expect(resizeTextarea).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('handleKeyDown', () => {
|
||||
const onPressEnter = jest.fn();
|
||||
const onKeyDown = jest.fn();
|
||||
const wrapper = mount(<TextArea onPressEnter={onPressEnter} onKeyDown={onKeyDown} />);
|
||||
wrapper.instance().handleKeyDown({ keyCode: 13 });
|
||||
expect(onPressEnter).toBeCalled();
|
||||
expect(onKeyDown).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('As Form Control', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user