update input test case

This commit is contained in:
afc163 2017-01-31 16:03:14 +08:00
parent 767c4ab70d
commit 7381cc95fe

View File

@ -8,9 +8,22 @@ const calculateNodeHeight = require('../calculateNodeHeight');
const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout));
describe('Input', () => { describe('Input', () => {
it('should not auto calculate height when type is text', async () => {
const wrapper = mount(
<Input value="" readOnly />
);
expect(calculateNodeHeight).toHaveBeenCalledTimes(0);
wrapper.setProps({ value: '1111\n2222\n3333' });
await delay(0);
expect(calculateNodeHeight).toHaveBeenCalledTimes(0);
wrapper.setProps({ value: '1111' });
await delay(0);
expect(calculateNodeHeight).toHaveBeenCalledTimes(0);
});
it('should auto calculate height according to content length', async () => { it('should auto calculate height according to content length', async () => {
const wrapper = mount( const wrapper = mount(
<Input type="textarea" autosize /> <Input value="" readOnly type="textarea" autosize />
); );
expect(calculateNodeHeight).toHaveBeenCalledTimes(1); expect(calculateNodeHeight).toHaveBeenCalledTimes(1);
wrapper.setProps({ value: '1111\n2222\n3333' }); wrapper.setProps({ value: '1111\n2222\n3333' });