From d87ea9c88a30938306052b25eddf7dd906f3cab9 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Fri, 18 Mar 2022 20:54:09 -0700 Subject: Fix JSON parsing failure --- integration/bunjs-only-snippets/fetch.test.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'integration/bunjs-only-snippets') diff --git a/integration/bunjs-only-snippets/fetch.test.js b/integration/bunjs-only-snippets/fetch.test.js index b1ab57366..2f976fd83 100644 --- a/integration/bunjs-only-snippets/fetch.test.js +++ b/integration/bunjs-only-snippets/fetch.test.js @@ -376,6 +376,21 @@ describe("Response", () => { expect(await clone.text()).toBe("
hello
"); gc(); }); + it("invalid json", async () => { + gc(); + var body = new Response("
hello
", { + headers: { + "content-type": "text/html; charset=utf-8", + }, + }); + try { + await body.json(); + expect(false).toBe(true); + } catch (exception) { + expect(exception instanceof SyntaxError); + } + }); + testBlobInterface((data) => new Response(data), true); }); -- cgit v1.2.3