Closed iyawnis closed 8 years ago
Using this library, is it possible to simulate touch events, for example clicking on a TouchableHighlight ? I am making use of enzyme with mocha and chain, but not sure how to approach this.
Here is an example of what I am trying:
<Component> <View> <TouchableHighlight onPress={this.props.buttonPressed}> <Text>{this.props.text}</Hello> </TouchableHighlight> </View> </Component>
it('should be pressed', () => { let buttonPressed = sinon.spy(); let wrapper = shallow(<Component text={'Hello'} onPress={buttonPressed} />); wrapper.children().forEach( n => { n.simulate('click')}); expect(onButtonClick.calledOnce).to.equal(true); });
@latusaki you should try simulating press instead of click. I believe this should work. Let me know if not!
press
click
:ohgodwhy:
Yes it is working, did not think that. :+1:
Using this library, is it possible to simulate touch events, for example clicking on a TouchableHighlight ? I am making use of enzyme with mocha and chain, but not sure how to approach this.
Here is an example of what I am trying: