aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/fetch.test.js
blob: 72b80cd35795e4bac2efb11a1609c876dfcbf72b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { it, describe } from "bun:test";
import fs from "fs";

describe("fetch", () => {
  const urls = ["https://example.com", "http://example.com"];
  for (let url of urls) {
    it(url, async () => {
      const response = await fetch(url);
      const text = await response.text();

      if (
        fs.readFileSync(
          import.meta.path.substring(0, import.meta.path.lastIndexOf("/")) +
            "/fetch.js.txt",
          "utf8"
        ) !== text
      ) {
        throw new Error("Expected fetch.js.txt to match snapshot");
      }
    });
  }
});