mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-01 13:16:55 +08:00
up
This commit is contained in:
parent
959987ad23
commit
4e331a5049
@ -44,6 +44,27 @@ describe('TextArea', () => {
|
|||||||
expect(mockFunc).toHaveBeenCalledTimes(2);
|
expect(mockFunc).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use settimeout when ', () => {
|
||||||
|
const backup = window.requestAnimationFrame;
|
||||||
|
const setTimeoutBackUp = window.setTimeout;
|
||||||
|
// window.requestAnimationFrame = null;
|
||||||
|
window.setTimeout = jest.fn((cb, time) => {
|
||||||
|
setTimeoutBackUp(cb, time);
|
||||||
|
});
|
||||||
|
const wrapper = mount(<TextArea value="" readOnly autosize />);
|
||||||
|
const mockFunc = jest.spyOn(wrapper.instance(), 'resizeTextarea');
|
||||||
|
wrapper.setProps({ value: '1111\n2222\n3333' });
|
||||||
|
jest.runAllTimers();
|
||||||
|
expect(window.setTimeout).toHaveBeenCalledTimes(1);
|
||||||
|
expect(mockFunc).toHaveBeenCalledTimes(1);
|
||||||
|
wrapper.setProps({ value: '1111' });
|
||||||
|
jest.runAllTimers();
|
||||||
|
expect(mockFunc).toHaveBeenCalledTimes(2);
|
||||||
|
expect(window.setTimeout).toHaveBeenCalledTimes(100);
|
||||||
|
window.setTimeout = setTimeoutBackUp;
|
||||||
|
window.requestAnimationFrame = backup;
|
||||||
|
});
|
||||||
|
|
||||||
it('should support disabled', () => {
|
it('should support disabled', () => {
|
||||||
const wrapper = mount(<TextArea disabled />);
|
const wrapper = mount(<TextArea disabled />);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
Loading…
Reference in New Issue
Block a user