/
moreqqq
/
DeliveryService
Обзор
Документация
Войти
/
moreqqq
/
DeliveryService
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
server/node_modules/node-abort-controller/__tests__/node-fetch.js
27 строк
886 B
moreqqq
написал приложение
29 май 2026, 22:02
29 май 2026, 22:02
ad51790
Код
Авторство
О чём код?
const { AbortController } = require("../index.js"); const fetch = require("node-fetch"); describe("node-fetch", function () { it("should throw exception if aborted during the request", async function () { expect.assertions(1); try { const controller = new AbortController(); const signal = controller.signal; setTimeout(() => controller.abort(), 5); await fetch("https://www.google.com/", { signal }); } catch (err) { expect(err.name).toBe("AbortError"); } }); it("should throw exception if passed an already aborted signal", async function () { expect.assertions(1); try { const controller = new AbortController(); const signal = controller.signal; controller.abort(); await fetch("https://www.google.com/", { signal }); } catch (err) { expect(err.name).toBe("AbortError"); } }); });