aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/serve.test.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-02 19:35:28 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-12-02 19:35:28 -0800
commit4e6b905a9891ef9cc5127335ea06ec087c5d4a61 (patch)
treefb9869bad0c8e216f9be94b945200e6eaa6d11f1 /test/bun.js/serve.test.ts
parent43f2a8eb852a1a57a9def2432e2e0d85df812dca (diff)
downloadbun-4e6b905a9891ef9cc5127335ea06ec087c5d4a61.tar.gz
bun-4e6b905a9891ef9cc5127335ea06ec087c5d4a61.tar.zst
bun-4e6b905a9891ef9cc5127335ea06ec087c5d4a61.zip
Update test
Diffstat (limited to '')
-rw-r--r--test/bun.js/serve.test.ts58
1 files changed, 33 insertions, 25 deletions
diff --git a/test/bun.js/serve.test.ts b/test/bun.js/serve.test.ts
index 6e5a0030a..8dc3e3d45 100644
--- a/test/bun.js/serve.test.ts
+++ b/test/bun.js/serve.test.ts
@@ -599,31 +599,6 @@ it("should support reloading", async () => {
server.stop();
});
-it("should support multiple Set-Cookie headers", async () => {
- const server = serve({
- port: port++,
- fetch(req) {
- return new Response("hello", {
- headers: [
- ["Another-Header", "1"],
- ["Set-Cookie", "foo=bar"],
- ["Set-Cookie", "baz=qux"],
- ],
- });
- },
- });
-
- const response = await fetch(`http://${server.hostname}:${server.port}`);
- server.stop();
-
- expect(response.headers.getAll("Set-Cookie")).toEqual(["foo=bar", "baz=qux"]);
- expect(response.headers.getSetCookie()).toEqual(["foo=bar", "baz=qux"]);
-
- const cloned = response.clone().headers;
- expect(cloned.getAll("Set-Cookie")).toEqual(["foo=bar", "baz=qux"]);
- expect(cloned.getSetCookie()).toEqual(["foo=bar", "baz=qux"]);
-});
-
describe("status code text", () => {
const fixture = {
200: "OK",
@@ -703,3 +678,36 @@ describe("status code text", () => {
});
}
});
+
+it("should support multiple Set-Cookie headers", async () => {
+ const server = serve({
+ port: port++,
+ fetch(req) {
+ return new Response("hello", {
+ headers: [
+ ["Another-Header", "1"],
+ ["Set-Cookie", "foo=bar"],
+ ["Set-Cookie", "baz=qux"],
+ ],
+ });
+ },
+ });
+
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
+ server.stop();
+
+ expect(response.headers.getAll("Set-Cookie")).toEqual(["foo=bar", "baz=qux"]);
+ expect(response.headers.get("Set-Cookie")).toEqual("foo=bar, baz=qux");
+
+ const cloned = response.clone().headers;
+ expect(response.headers.getAll("Set-Cookie")).toEqual(["foo=bar", "baz=qux"]);
+
+ response.headers.delete("Set-Cookie");
+ expect(response.headers.getAll("Set-Cookie")).toEqual([]);
+ response.headers.delete("Set-Cookie");
+ expect(cloned.getAll("Set-Cookie")).toEqual(["foo=bar", "baz=qux"]);
+ expect(new Headers(cloned).getAll("Set-Cookie")).toEqual([
+ "foo=bar",
+ "baz=qux",
+ ]);
+});