diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-05-10 03:20:18 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-09 19:20:18 +0200 |
commit | 670d01d0126d80c0acfd22a76148dcbd831763cb (patch) | |
tree | da2ed9292b49a3b01ecdbd7adc56a02acc52ca0e /cli/js/tests/headers_test.ts | |
parent | 7a635eda5e9132558ad23ea6147ab2fb3764dbdd (diff) |
fix: Allow multiple Set-Cookie headers (#5100)
Diffstat (limited to 'cli/js/tests/headers_test.ts')
-rw-r--r-- | cli/js/tests/headers_test.ts | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/cli/js/tests/headers_test.ts b/cli/js/tests/headers_test.ts index 0711a7736..aaa829837 100644 --- a/cli/js/tests/headers_test.ts +++ b/cli/js/tests/headers_test.ts @@ -332,6 +332,66 @@ unitTest(function headerParamsArgumentsCheck(): void { }); }); +unitTest(function headersInitMultiple(): void { + const headers = new Headers([ + ["Set-Cookie", "foo=bar"], + ["Set-Cookie", "bar=baz"], + ["X-Deno", "foo"], + ["X-Deno", "bar"], + ]); + const actual = [...headers]; + assertEquals(actual, [ + ["set-cookie", "foo=bar"], + ["set-cookie", "bar=baz"], + ["x-deno", "foo, bar"], + ]); +}); + +unitTest(function headersAppendMultiple(): void { + const headers = new Headers([ + ["Set-Cookie", "foo=bar"], + ["X-Deno", "foo"], + ]); + headers.append("set-Cookie", "bar=baz"); + headers.append("x-Deno", "bar"); + const actual = [...headers]; + assertEquals(actual, [ + ["set-cookie", "foo=bar"], + ["x-deno", "foo, bar"], + ["set-cookie", "bar=baz"], + ]); +}); + +unitTest(function headersAppendDuplicateSetCookieKey(): void { + const headers = new Headers([["Set-Cookie", "foo=bar"]]); + headers.append("set-Cookie", "foo=baz"); + headers.append("Set-cookie", "baz=bar"); + const actual = [...headers]; + assertEquals(actual, [ + ["set-cookie", "foo=baz"], + ["set-cookie", "baz=bar"], + ]); +}); + +unitTest(function headersSetDuplicateCookieKey(): void { + const headers = new Headers([["Set-Cookie", "foo=bar"]]); + headers.set("set-Cookie", "foo=baz"); + headers.set("set-cookie", "bar=qat"); + const actual = [...headers]; + assertEquals(actual, [ + ["set-cookie", "foo=baz"], + ["set-cookie", "bar=qat"], + ]); +}); + +unitTest(function headersGetSetCookie(): void { + const headers = new Headers([ + ["Set-Cookie", "foo=bar"], + ["set-Cookie", "bar=qat"], + ]); + assertEquals(headers.get("SET-COOKIE"), "foo=bar, bar=qat"); +}); + unitTest(function toStringShouldBeWebCompatibility(): void { const headers = new Headers(); assertEquals(headers.toString(), "[object Headers]"); |