mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-01 11:39:28 +08:00
test input auto calculate height
This commit is contained in:
parent
30b2fa2c37
commit
3a3efc3e5a
23
components/input/__tests__/index.test.js
Normal file
23
components/input/__tests__/index.test.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { mount } from 'enzyme';
|
||||||
|
import Input from '..';
|
||||||
|
|
||||||
|
jest.mock('../calculateNodeHeight');
|
||||||
|
const calculateNodeHeight = require('../calculateNodeHeight');
|
||||||
|
|
||||||
|
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
|
||||||
|
|
||||||
|
describe('Input', () => {
|
||||||
|
it('should auto calculate height according to content length', async () => {
|
||||||
|
const wrapper = mount(
|
||||||
|
<Input type="textarea" autosize />
|
||||||
|
);
|
||||||
|
expect(calculateNodeHeight).toHaveBeenCalledTimes(1);
|
||||||
|
wrapper.setProps({ value: '1111\n2222\n3333' });
|
||||||
|
await delay(0);
|
||||||
|
expect(calculateNodeHeight).toHaveBeenCalledTimes(2);
|
||||||
|
wrapper.setProps({ value: '1111' });
|
||||||
|
await delay(0);
|
||||||
|
expect(calculateNodeHeight).toHaveBeenCalledTimes(3);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user