summaryrefslogtreecommitdiff
path: root/js/fetch_test.ts
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2019-09-08 01:20:30 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-09-07 12:20:30 -0400
commita205e8a3c2bf5ba72fe18bd7f224303338956c62 (patch)
tree5f8f1af99c5429a69a351c22440b2d907de4720a /js/fetch_test.ts
parent8e3c879d1387d8b618904bf0bc8bc23e77a1114c (diff)
fetch: implement bodyUsed (#2877)
Diffstat (limited to 'js/fetch_test.ts')
-rw-r--r--js/fetch_test.ts21
1 files changed, 20 insertions, 1 deletions
diff --git a/js/fetch_test.ts b/js/fetch_test.ts
index 8d8b581d8..083d5333c 100644
--- a/js/fetch_test.ts
+++ b/js/fetch_test.ts
@@ -1,5 +1,11 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { test, testPerm, assert, assertEquals } from "./test_util.ts";
+import {
+ test,
+ testPerm,
+ assert,
+ assertEquals,
+ assertThrows
+} from "./test_util.ts";
testPerm({ net: true }, async function fetchJsonSuccess(): Promise<void> {
const response = await fetch("http://localhost:4545/package.json");
@@ -38,6 +44,19 @@ testPerm({ net: true }, async function fetchBlob(): Promise<void> {
assertEquals(blob.size, Number(headers.get("Content-Length")));
});
+testPerm({ net: true }, async function fetchBodyUsed(): Promise<void> {
+ const response = await fetch("http://localhost:4545/package.json");
+ assertEquals(response.bodyUsed, false);
+ assertThrows(
+ (): void => {
+ // Assigning to read-only property throws in the strict mode.
+ response.bodyUsed = true;
+ }
+ );
+ await response.blob();
+ assertEquals(response.bodyUsed, true);
+});
+
testPerm({ net: true }, async function fetchAsyncIterator(): Promise<void> {
const response = await fetch("http://localhost:4545/package.json");
const headers = response.headers;