aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/fetch/body-mixin-errors.test.ts
blob: f57bbc56cf26fcee241f01e0c94cb388a4d79894 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { it, describe, expect } from "bun:test";

describe("body-mixin-errors", () => {
  it("should fail when bodyUsed", async () => {
    var res = new Response("a");
    expect(res.bodyUsed).toBe(false);
    await res.text();
    expect(res.bodyUsed).toBe(true);

    try {
      await res.text();
      throw new Error("should not get here");
    } catch (e: any) {
      expect(e.message).toBe("Body already used");
    }
  });
});