I am having trouble with passing a test spec (below) that after a fetch failure, the spy log would be called. The failure reference is "Expected spy log to have been called". The function I call within handleErrors will output the expected, so the spy log is the only thing I am trying to understand. Any advice would be greatly appreciated! thank you.
//Test
it('should recover on fetch error', function(done){
window.path = "xyz";
spyOn(console, "log").and.callFake(function(){});
function check(output) {
window.path = "xyy";
expect(console.log).toHaveBeenCalled();
console.log.calls.reset();
retrieve().then(function(output){
var expected = {expectedOutput}
expect(output).toEqual(expected);
expect(console.log).not.toHaveBeenCalled();
done();
});
}
retrieve().then(check);
});
//function
function handleErrors(response) {
if (!response.ok) {
normalRetrieve()
}
return response;
}
//directly after fetch request
.then(handleErrors)
Aucun commentaire:
Enregistrer un commentaire