summaryrefslogtreecommitdiff
path: root/cli/tests/unit/fetch_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/unit/fetch_test.ts')
-rw-r--r--cli/tests/unit/fetch_test.ts55
1 files changed, 54 insertions, 1 deletions
diff --git a/cli/tests/unit/fetch_test.ts b/cli/tests/unit/fetch_test.ts
index c22fc5226..cbd0139a3 100644
--- a/cli/tests/unit/fetch_test.ts
+++ b/cli/tests/unit/fetch_test.ts
@@ -1272,7 +1272,60 @@ Deno.test(
} catch (error) {
assert(error instanceof DOMException);
assertEquals(error.name, "AbortError");
- assertEquals(error.message, "Ongoing fetch was aborted.");
+ assertEquals(error.message, "The signal has been aborted");
+ }
+ },
+);
+
+Deno.test(
+ { permissions: { net: true } },
+ async function fetchAbortWhileUploadStreamingWithReason(): Promise<void> {
+ const abortController = new AbortController();
+ const abortReason = new Error();
+ try {
+ await fetch(
+ "http://localhost:5552/echo_server",
+ {
+ method: "POST",
+ body: new ReadableStream({
+ pull(controller) {
+ abortController.abort(abortReason);
+ controller.enqueue(new Uint8Array([1, 2, 3, 4]));
+ },
+ }),
+ signal: abortController.signal,
+ },
+ );
+ fail("Fetch didn't reject.");
+ } catch (error) {
+ assertEquals(error, abortReason);
+ }
+ },
+);
+
+Deno.test(
+ { permissions: { net: true } },
+ async function fetchAbortWhileUploadStreamingWithPrimitiveReason(): Promise<
+ void
+ > {
+ const abortController = new AbortController();
+ try {
+ await fetch(
+ "http://localhost:5552/echo_server",
+ {
+ method: "POST",
+ body: new ReadableStream({
+ pull(controller) {
+ abortController.abort("Abort reason");
+ controller.enqueue(new Uint8Array([1, 2, 3, 4]));
+ },
+ }),
+ signal: abortController.signal,
+ },
+ );
+ fail("Fetch didn't reject.");
+ } catch (error) {
+ assertEquals(error, "Abort reason");
}
},
);