diff options
author | 2023-07-11 19:14:34 -0700 | |
---|---|---|
committer | 2023-07-11 19:14:34 -0700 | |
commit | cbb88672f217a90db1aa1eb29cd92d5d9035b22b (patch) | |
tree | 43a00501f3cde495967e116f0b660777051551f8 /test/js/web/fetch/fetch.test.ts | |
parent | 1f900cff453700b19bca2acadfe26da4468c1282 (diff) | |
parent | 34b0e7a2bbd8bf8097341cdb0075d0908283e834 (diff) | |
download | bun-jarred/esm-conditions.tar.gz bun-jarred/esm-conditions.tar.zst bun-jarred/esm-conditions.zip |
Merge branch 'main' into jarred/esm-conditionsjarred/esm-conditions
Diffstat (limited to 'test/js/web/fetch/fetch.test.ts')
-rw-r--r-- | test/js/web/fetch/fetch.test.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts index 4d529b231..768818420 100644 --- a/test/js/web/fetch/fetch.test.ts +++ b/test/js/web/fetch/fetch.test.ts @@ -387,6 +387,25 @@ describe("fetch", () => { }).toThrow("fetch() request with GET/HEAD/OPTIONS method cannot have body."); }), ); + + it("content length is inferred", async () => { + startServer({ + fetch(req) { + return new Response(req.headers.get("content-length")); + }, + hostname: "localhost", + }); + + // POST with body + const url = `http://${server.hostname}:${server.port}`; + const response = await fetch(url, { method: "POST", body: "buntastic" }); + expect(response.status).toBe(200); + expect(await response.text()).toBe("9"); + + const response2 = await fetch(url, { method: "POST", body: "" }); + expect(response2.status).toBe(200); + expect(await response2.text()).toBe("0"); + }); }); it("simultaneous HTTPS fetch", async () => { @@ -1156,6 +1175,10 @@ it("#2794", () => { expect(typeof Bun.fetch.bind).toBe("function"); }); +it("#3545", () => { + expect(() => fetch("http://example.com?a=b")).not.toThrow(); +}); + it("invalid header doesnt crash", () => { expect(() => fetch("http://example.com", { |