From 1239c9460ac1d10376e27653b4c34d789f2a8f43 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:32:23 -0700 Subject: fix iterating headers with `set-cookie` (#4048) * fix iterating headers with `set-cookie` * a test * move work to `HTTPHeaderMap::set` * append set-cookie after sort * remove compare function --- test/js/web/fetch/fetch.test.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'test/js/web/fetch/fetch.test.ts') diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts index ec73069de..a1585ba14 100644 --- a/test/js/web/fetch/fetch.test.ts +++ b/test/js/web/fetch/fetch.test.ts @@ -234,11 +234,11 @@ describe("Headers", () => { ]); const actual = [...headers]; expect(actual).toEqual([ + ["x-bun", "abc, def"], ["set-cookie", "foo=bar"], ["set-cookie", "bar=baz"], - ["x-bun", "abc, def"], ]); - expect([...headers.values()]).toEqual(["foo=bar", "bar=baz", "abc, def"]); + expect([...headers.values()]).toEqual(["abc, def", "foo=bar", "bar=baz"]); }); it("Headers append multiple", () => { @@ -253,9 +253,9 @@ describe("Headers", () => { // we do not preserve the order // which is kind of bad expect(actual).toEqual([ + ["x-bun", "foo, bar"], ["set-cookie", "foo=bar"], ["set-cookie", "bar=baz"], - ["x-bun", "foo, bar"], ]); }); @@ -276,9 +276,17 @@ describe("Headers", () => { headers.set("set-Cookie", "foo=baz"); headers.set("set-cookie", "bar=qat"); const actual = [...headers]; + expect(actual).toEqual([["set-cookie", "bar=qat"]]); + }); + + it("should include set-cookie headers in array", () => { + const headers = new Headers(); + headers.append("Set-Cookie", "foo=bar"); + headers.append("Content-Type", "text/plain"); + const actual = [...headers]; expect(actual).toEqual([ - ["set-cookie", "foo=baz"], - ["set-cookie", "bar=qat"], + ["content-type", "text/plain"], + ["set-cookie", "foo=bar"], ]); }); }); -- cgit v1.2.3