This is a cancel button
<div className="cancelFileBtn" onClick={this.props.cancelFileSending}>
I need to simulate its click,I tried the following test
wrapper.find('.cancelFileBtn').simulate('click');
But the click function is still undefined...Did I miss anything else? and it will be very helpful if anyone can mention any changes if exist in simulating
<SendMessageButton onClick={this.props.handleClickSendMessage} loadingFile={this.props.loadingFile}/>
Can't tell much without seeing more codes, hope this helps:
const wrapper = mount(<Component />);
const cancelBtn = wrapper.find('.cancelFileBtn');
// Test that the button is truthy
expect(cancelBtn).to.have.length(1);
// Simulation
cancelBtn.simulate('click');
// or
cancelBtn.props().onClick();
// Test the output
expect(...).to.equal(...);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With