diff options
author | Luca Casonato <hello@lcas.dev> | 2024-11-15 15:54:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 15:54:28 +0100 |
commit | b8cf2599242a9d85d03b57d3649ccdf8bce1530e (patch) | |
tree | 87a6288f2174aa6d22730a9ec020292b778c9dca /tests/unit_node | |
parent | 3f26310728ef2d56ace7370a555eb9a862295983 (diff) |
feat(fetch): accept async iterables for body (#26882)
Reland of #24623, but with a fix for `String` objects.
Co-authored-by: crowlkats <crowlkats@toaxl.com>
Diffstat (limited to 'tests/unit_node')
-rw-r--r-- | tests/unit_node/fetch_test.ts | 18 |
1 files changed, 18 insertions, 0 deletions
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"), + ); +}); |