Enzyme: How to simulate the Switch Component OnValueChange prop in react-native

Created on 24 Sep 2016  路  2Comments  路  Source: enzymejs/enzyme

wrapper.find(Switch).at(0).simulate('onValueChange',true); expect(wrapper.state('switchStatus')).to.equal(true);

Fails the test.

Most helpful comment

Just drop the "on" to find the event name, like so:

wrapper.find(Switch).at(0).simulate('valueChange')

All 2 comments

Just drop the "on" to find the event name, like so:

wrapper.find(Switch).at(0).simulate('valueChange')

You'd need a react native adapter to use enzyme with React Native.

Closing this in favor of #1436.

Was this page helpful?
0 / 5 - 0 ratings