From 6ecc86cf2ae4bb0aac6f3d0e954382a69176b387 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 28 Jan 2021 21:37:21 +0100 Subject: chore: add jsdoc to 26_fetch.js and enable some fetch tests (#9305) --- cli/tests/unit/request_test.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'cli/tests/unit/request_test.ts') 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 { 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 { + 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 { const b2 = await r2.text(); assertEquals(b1, b2); - - // deno-lint-ignore no-explicit-any - assert((r1 as any)._bodySource !== (r2 as any)._bodySource); }); -- cgit v1.2.3