diff options
author | 2022-10-15 21:34:05 -0700 | |
---|---|---|
committer | 2022-10-15 21:34:05 -0700 | |
commit | c06bba77d46fc5fcdb2ca21591cbf94b8fa4e6ba (patch) | |
tree | 215bc35017d81ed455b15d3f62396f685bc94cc9 | |
parent | 4ba217bc42e7f4d70487266c93dca9785bf23159 (diff) | |
download | bun-c06bba77d46fc5fcdb2ca21591cbf94b8fa4e6ba.tar.gz bun-c06bba77d46fc5fcdb2ca21591cbf94b8fa4e6ba.tar.zst bun-c06bba77d46fc5fcdb2ca21591cbf94b8fa4e6ba.zip |
Add test for body mixin error
-rw-r--r-- | test/bun.js/body-mixin-errors.test.ts | 17 |
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"); + } + }); +}); |