Good day. I am coding some tests and i am not really sure how to check if a pushRoute function has actually sent me to the page i want.
Here's an edited code of the component and the test i am trying to perform.
Component:
redirectToRoute= () => {
this.props.pushRoute('/some/route')
}
<SomeComponent
title="Some Title"
value={value}
onClick={() => this.redirectToRoute()}
/>
Test:
it('Should redirect to route', () => {
const pushRoute = jest.fn();
const wrapper = setup({ pushRoute });
wrapper.instance().redirectToRoute();
expect(pushRoute).toHaveBeenCalledTimes(1);
});
In here i can test if onClick has been called but i don't now how to checkout if it redirects to the route i want.
Aucun commentaire:
Enregistrer un commentaire