Skip to content

Commit

Permalink
[Select] Test if child passed to onChange handler (mui#12852)
Browse files Browse the repository at this point in the history
* [Select] Test if child passed to onChange handler
mui#12739

* [Select] Test if child passed to onChange handler
mui#12739
  • Loading branch information
akaxiaok authored and marcelpanse committed Oct 2, 2018
1 parent 8220874 commit 733d2b0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/material-ui/src/Select/Select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createShallow, getClasses, createMount } from '../test-utils';
import MenuItem from '../MenuItem';
import Input from '../Input';
import Select from './Select';
import { spy } from 'sinon';

describe('<Select />', () => {
let shallow;
Expand Down Expand Up @@ -64,4 +65,17 @@ describe('<Select />', () => {
);
assert.strictEqual(wrapper.find('input').props().value, 10);
});
describe('prop: onChange', () => {
it('should get selected element from arguments', () => {
const onChangeHandler = spy();
const wrapper = mount(<Select onChange={onChangeHandler} {...defaultProps} value={'1'} />);
wrapper.find('[role="button"]').simulate('click');
wrapper
.find(MenuItem)
.at(1)
.simulate('click');
const selected = onChangeHandler.args[0][1];
assert.strictEqual(React.isValidElement(selected), true, 'should b be a element');
});
});
});

0 comments on commit 733d2b0

Please sign in to comment.