aboutsummaryrefslogtreecommitdiff
path: root/integration/bunjs-only-snippets/fetch.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-03-18 20:54:09 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2022-03-18 20:54:09 -0700
commitd87ea9c88a30938306052b25eddf7dd906f3cab9 (patch)
tree07bd4b5b3f2379c9eda41bf3ccb7148dc9ddf9af /integration/bunjs-only-snippets/fetch.test.js
parent7dc76bf70902de10cb4f4752dae4c7e90cfc1027 (diff)
downloadbun-d87ea9c88a30938306052b25eddf7dd906f3cab9.tar.gz
bun-d87ea9c88a30938306052b25eddf7dd906f3cab9.tar.zst
bun-d87ea9c88a30938306052b25eddf7dd906f3cab9.zip
Fix JSON parsing failure
Diffstat (limited to 'integration/bunjs-only-snippets/fetch.test.js')
-rw-r--r--integration/bunjs-only-snippets/fetch.test.js15
1 files changed, 15 insertions, 0 deletions
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("<div>hello</div>");
gc();
});
+ it("invalid json", async () => {
+ gc();
+ var body = new Response("<div>hello</div>", {
+ 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);
});