diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-01-28 21:37:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-28 21:37:21 +0100 |
commit | 6ecc86cf2ae4bb0aac6f3d0e954382a69176b387 (patch) | |
tree | 8405d5a781abda4e59b508af2e6b5beaba86db88 /cli/tests/unit/request_test.ts | |
parent | 7bda0f567ec7e1a688b41b6026c6124656cd413a (diff) |
chore: add jsdoc to 26_fetch.js and enable some fetch tests (#9305)
Diffstat (limited to 'cli/tests/unit/request_test.ts')
-rw-r--r-- | cli/tests/unit/request_test.ts | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/cli/tests/unit/request_test.ts b/cli/tests/unit/request_test.ts index 0214d99c3..a8cbed370 100644 --- a/cli/tests/unit/request_test.ts +++ b/cli/tests/unit/request_test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -import { assert, assertEquals, unitTest } from "./test_util.ts"; +import { assertEquals, unitTest } from "./test_util.ts"; -unitTest(function fromInit(): void { +unitTest(async function fromInit(): Promise<void> { const req = new Request("http://foo/", { body: "ahoyhoy", method: "POST", @@ -10,22 +10,18 @@ unitTest(function fromInit(): void { }, }); - // deno-lint-ignore no-explicit-any - assertEquals("ahoyhoy", (req as any)._bodySource); + assertEquals("ahoyhoy", await req.text()); assertEquals(req.url, "http://foo/"); assertEquals(req.headers.get("test-header"), "value"); }); -unitTest(function fromRequest(): void { - const r = new Request("http://foo/"); - // deno-lint-ignore no-explicit-any - (r as any)._bodySource = "ahoyhoy"; +unitTest(async function fromRequest(): Promise<void> { + const r = new Request("http://foo/", { body: "ahoyhoy" }); r.headers.set("test-header", "value"); const req = new Request(r); - // deno-lint-ignore no-explicit-any - assertEquals((req as any)._bodySource, (r as any)._bodySource); + assertEquals(await r.text(), await req.text()); assertEquals(req.url, r.url); assertEquals(req.headers.get("test-header"), r.headers.get("test-header")); }); @@ -65,7 +61,4 @@ unitTest(async function cloneRequestBodyStream(): Promise<void> { const b2 = await r2.text(); assertEquals(b1, b2); - - // deno-lint-ignore no-explicit-any - assert((r1 as any)._bodySource !== (r2 as any)._bodySource); }); |