mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Update test
This commit is contained in:
@@ -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",
|
||||
]);
|
||||
|
||||
@@ -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",
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user