Reputation: 466
There is a function in my parent class that is being sent to the Child component, it is not being used else where. How can I achieve coverage for this code. I want to avoid using mount
and use shallow
only.
class Parent extends React.Component {
callBackFn() {
console.log("Some call back function");
}
render(){
return (<div>
<ChildComponent someFunct="callBackFn" />
</div>);
}
}
Upvotes: 1
Views: 47
Reputation: 741
let wrapper = shallow(<Parent/>);
wrapper.find(ChildComponent).prop('someFunct')();
This can execute your function and code will get covered.
Upvotes: 1