summaryrefslogtreecommitdiff
path: root/tests/unit_node/fetch_test.ts
blob: 399d6052a563771310969d2834dbb9ad69917c43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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"),
  );
});