diff --git a/src/components/Select.js b/src/components/Select.js index 9da7d87de..5b04c117f 100644 --- a/src/components/Select.js +++ b/src/components/Select.js @@ -22,7 +22,7 @@ class Select2 extends Component { } } - updateValue = ({ value }) => { this.setState({ value })} + updateValue = value => { this.setState({ value }); } render() { const { value, ...props } = this.props; diff --git a/test/components/Select.spec.js b/test/components/Select.spec.js index 06644359b..e1842d0d7 100644 --- a/test/components/Select.spec.js +++ b/test/components/Select.spec.js @@ -3,7 +3,7 @@ import 'jsdom-global/register'; import React from 'react'; import assert from 'assert'; -import { mount, shallow } from 'enzyme'; +import { shallow } from 'enzyme'; import Select from 'react-select'; import Select2 from '../../src/components/Select.js'; @@ -21,9 +21,14 @@ describe('', () => { }); it('should update the value when changed', () => { - component.simulate('change', { value: 4 }); - assert.equal(component.prop('value'), 4); + component.simulate('change', 'stuff'); + assert.equal(component.prop('value'), 'stuff'); }); }); + }); - describe('controlled', () => { - const component = shallow(); + describe('controlled', () => { + const component = shallow(); - it('should render with the given value', () => { - assert.equal(component.prop('value'), 3); - }); + it('should render with the given value', () => { + assert.equal(component.prop('value'), 3); + }); - it('should not update the value when changed', () => { - component.simulate('change', { value: 4 }); - assert.equal(component.prop('value'), 3); - }); + it('should not update the value when changed', () => { + component.simulate('change', OPTIONS[3]); + assert.equal(component.prop('value'), 3); }); }); @@ -63,7 +68,8 @@ describe('