diff --git a/src/input/Input.jsx b/src/input/Input.jsx index 3be5a7dff..a2a3ffb8d 100644 --- a/src/input/Input.jsx +++ b/src/input/Input.jsx @@ -58,7 +58,7 @@ export default class Input extends Component { const { onChange } = this.props; if (onChange) { - onChange(e.target.value); + onChange(e); } this.resizeTextarea(); } diff --git a/src/input/__test__/Input_test.jsx b/src/input/__test__/Input_test.jsx index 5efa6e226..b57d0e533 100644 --- a/src/input/__test__/Input_test.jsx +++ b/src/input/__test__/Input_test.jsx @@ -1,10 +1,10 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { mount, shallow } from 'enzyme'; import sinon from 'sinon'; import Input from '../'; -// const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); +// const dInputelay = timeout => new Promise(resolve => setTimeout(resolve, timeout)); describe('Input test', () => { it('create', () => { @@ -65,4 +65,16 @@ describe('Input test', () => { expect(w.find('.el-textarea__inner').first().prop('style').resize).toBe('both'); }); + it('onChange', (done) => { + const updateValue = function(event) { + expect(event.target).toBeInstanceOf(EventTarget); + done(); + }; + + const w = mount( + + ); + + w.find('input').simulate('change'); + }); });