diff options
Diffstat (limited to 'test/bun.js/FormData.test.ts')
-rw-r--r-- | test/bun.js/FormData.test.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/bun.js/FormData.test.ts b/test/bun.js/FormData.test.ts index b9d0f0856..dbe1a8ef0 100644 --- a/test/bun.js/FormData.test.ts +++ b/test/bun.js/FormData.test.ts @@ -307,6 +307,8 @@ describe("FormData", () => { const formData = new FormData(); formData.append("foo", Bun.file(path)); const response = C === Response ? new Response(formData) : new Request({ body: formData }); + expect(response.headers.get("content-type")?.startsWith("multipart/form-data;")).toBe(true); + const formData2 = await response.formData(); expect(formData2 instanceof FormData).toBe(true); expect(formData2.get("foo") instanceof Blob).toBe(true); @@ -335,6 +337,20 @@ describe("FormData", () => { expect(formData.get("baz")).toBe("qux"); }); + test("should parse URLSearchParams", async () => { + const searchParams = new URLSearchParams("foo=bar&baz=qux"); + const response = new Response(searchParams); + expect(response.headers.get("Content-Type")).toBe("application/x-www-form-urlencoded;charset=UTF-8"); + + expect(searchParams instanceof URLSearchParams).toBe(true); + expect(searchParams.get("foo")).toBe("bar"); + + const formData = await response.formData(); + expect(formData instanceof FormData).toBe(true); + expect(formData.get("foo")).toBe("bar"); + expect(formData.get("baz")).toBe("qux"); + }); + test("should parse URL encoded with charset", async () => { const response = new Response("foo=bar&baz=qux", { headers: { |