I'm having trouble setting up a just test case for this block of code.
fetchCustomers = () => {
axios
.get(URL)
.then((response) => {
this.setState({ customers: response });
})
.catch((error) => {
console.log(error);
});
};
Here is what I tried so far
fetchMock.get("/api/customer/3", () => {
return [{id:1, name: 'customer1', number: 23}];
});
wrapper.instance().fetchCustomers();
expect(wrapper.state()).toEqual({
customers: [{id:1, name: 'customer1', number: 23}]
});
When I look at my code coverage it just tells me that I haven't got to the then part of the cascade and the error.
Any help would be appreciated!