From 996e5dd235172bb14d286add7313306a8a8b772c Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Tue, 15 Nov 2022 18:31:22 -0800 Subject: Add test for non-standard Headers API additions --- test/bun.js/fetch.test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/bun.js/fetch.test.js') diff --git a/test/bun.js/fetch.test.js b/test/bun.js/fetch.test.js index ebcdcbc8b..d36932e42 100644 --- a/test/bun.js/fetch.test.js +++ b/test/bun.js/fetch.test.js @@ -8,6 +8,30 @@ const exampleFixture = fs.readFileSync( "utf8", ); +describe("Headers", () => { + it(".toJSON", () => { + var headers = new Headers({ + "content-length": "123", + "content-type": "text/plain", + "x-another-custom-header": "Hello World", + "x-custom-header": "Hello World", + }); + expect(JSON.stringify(headers.toJSON(), null, 2)).toBe( + JSON.stringify(Object.fromEntries(headers.entries()), null, 2), + ); + }); + + it(".count", () => { + var headers = new Headers({ + "content-length": "123", + "content-type": "text/plain", + "x-another-custom-header": "Hello World", + "x-custom-header": "Hello World", + }); + expect(headers.count).toBe(4); + }); +}); + describe("fetch", () => { const urls = [ "https://example.com", -- cgit v1.2.3