Last active
December 6, 2018 08:06
-
-
Save nghiaht/0d0e328db5d3689b52ef1cf45f5875e2 to your computer and use it in GitHub Desktop.
Jest Enzyme: onChange for material-ui Select (SelectInput - react-admin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleSubmit = sinon.spy(); | |
const wrapper = mount( | |
<Provider store={store}> | |
<MyForm onSubmit={handleSubmit} /> | |
</Provider> | |
); | |
// Assume MyForm having a platform select input whose name is "platform" | |
const elem = wrapper.find("Select[name='platform']"); | |
elem.prop("onChange")("iOS"); // Get onChange and call directly instead of the traditional elem.simulate("change", {target: {value: "iOS"}}) for <select> or <input> | |
expect(handleSubmit.getCall(0).args[0]).toMatchObject({ platform: "iOS" }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment