Invokes an event handler (a prop that matches the event name).
event
(String
): The event name to be invoked...args
(Any
[optional]): Arguments that will be passed to the event handler
Any
: Returns the value from the event handler..
class Foo extends React.Component {
loadData() {
return fetch();
}
render() {
return (
<a onClick={() => this.loadData()}>
Load more
</a>
);
}
}
const wrapper = shallow(<Foo />);
wrapper.invoke('click').then(() => {
// expect()
});