aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/bun.js/fetch.test.js4
-rw-r--r--test/bun.js/serve.test.ts58
2 files changed, 35 insertions, 27 deletions
diff --git a/test/bun.js/fetch.test.js b/test/bun.js/fetch.test.js
index e62022363..ca8e387bf 100644
--- a/test/bun.js/fetch.test.js
+++ b/test/bun.js/fetch.test.js
@@ -31,7 +31,7 @@ describe("Headers", () => {
"Set-Cookie": "foo=bar; Path=/; HttpOnly",
});
expect(headers.count).toBe(5);
- expect(headers.getSetCookie()).toEqual(["foo=bar; Path=/; HttpOnly"]);
+ expect(headers.getAll("set-cookie")).toEqual(["foo=bar; Path=/; HttpOnly"]);
});
it(".getSetCookie() with array", () => {
@@ -44,7 +44,7 @@ describe("Headers", () => {
["Set-Cookie", "foo2=bar2; Path=/; HttpOnly"],
]);
expect(headers.count).toBe(6);
- expect(headers.getSetCookie()).toEqual([
+ expect(headers.getAll("set-cookie")).toEqual([
"foo=bar; Path=/; HttpOnly",
"foo2=bar2; Path=/; HttpOnly",
]);
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",
+ ]);
+});