From ba40347a35d10cffeae83ee95f69f7bc281096dd Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Tue, 6 Aug 2024 00:13:02 -0700 Subject: feat(fetch): accept async iterables for body (#24623) Implements https://github.com/whatwg/webidl/pull/1397 Fixes #21454 Closes #24849 --- tests/unit_node/fetch_test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/unit_node/fetch_test.ts (limited to 'tests/unit_node') diff --git a/tests/unit_node/fetch_test.ts b/tests/unit_node/fetch_test.ts new file mode 100644 index 000000000..399d6052a --- /dev/null +++ b/tests/unit_node/fetch_test.ts @@ -0,0 +1,18 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +import { assertEquals } from "@std/assert"; +import { createReadStream } from "node:fs"; + +Deno.test("fetch node stream", async () => { + const file = createReadStream("tests/testdata/assets/fixture.json"); + + const response = await fetch("http://localhost:4545/echo_server", { + method: "POST", + body: file, + }); + + assertEquals( + await response.text(), + await Deno.readTextFile("tests/testdata/assets/fixture.json"), + ); +}); -- cgit v1.2.3