I am trying to test a component that makes 2 fetch calls inside the used hook:
useEffect(() => {
let viewCodePromise = getCode(id);
viewCodePromise.then(data => {
if (data.success === 1) {
setCode(data.code);
} else {
setError(data.error);
}
});
let getCommentsPromise = getComments(id);
getCommentsPromise.then(data => {
if (data.success === 1) {
setComments(data.comments);
} else {
setError(data.error);
}
});
}, []);
the functions getCode() and getComments() are making the fetch calls. How can I mock tests with jest both fetch calls?