main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
892 bytes
|
Line | |
---|
1 | const { AbortController } = require("../index.js");
|
---|
2 | const { fetch } = require("whatwg-fetch");
|
---|
3 |
|
---|
4 | describe("node-fetch", function () {
|
---|
5 | it("should throw exception if aborted during the request", async function () {
|
---|
6 | expect.assertions(1);
|
---|
7 | try {
|
---|
8 | const controller = new AbortController();
|
---|
9 | const signal = controller.signal;
|
---|
10 | setTimeout(() => controller.abort(), 5);
|
---|
11 | await fetch("https://www.google.com/", { signal });
|
---|
12 | } catch (err) {
|
---|
13 | expect(err.name).toBe("AbortError");
|
---|
14 | }
|
---|
15 | });
|
---|
16 | it("should throw exception if passed an already aborted signal", async function () {
|
---|
17 | expect.assertions(1);
|
---|
18 | try {
|
---|
19 | const controller = new AbortController();
|
---|
20 | const signal = controller.signal;
|
---|
21 | controller.abort();
|
---|
22 | await fetch("https://www.google.com/", { signal });
|
---|
23 | } catch (err) {
|
---|
24 | expect(err.name).toBe("AbortError");
|
---|
25 | }
|
---|
26 | });
|
---|
27 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.