From 03228d1ffea5f33d580dd503e5d17144d0ed39f2 Mon Sep 17 00:00:00 2001 From: Bruno Arsene Date: Tue, 19 Dec 2017 22:26:26 +0100 Subject: [PATCH] Pass event instead of value to input's onChange --- src/input/Input.jsx | 2 +- src/input/__test__/Input_test.jsx | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) 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'); + }); });