aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/bun.js/body-mixin-errors.test.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/bun.js/body-mixin-errors.test.ts b/test/bun.js/body-mixin-errors.test.ts
new file mode 100644
index 000000000..cec812c3f
--- /dev/null
+++ b/test/bun.js/body-mixin-errors.test.ts
@@ -0,0 +1,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) {
+ expect(e.message).toBe("Body already used");
+ }
+ });
+});