У меня проблемы с передачей тестовой спецификации (ниже), что после сбоя извлечения будет вызван журнал шпионов. Ссылка на ошибку «Ожидается, что журнал шпионов был вызван». Функция, которую я вызываю в handleErrors, выведет ожидаемый результат, поэтому я пытаюсь понять журнал шпионов. Любой совет будет принята с благодарностью! спасибо.
//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)