You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
880 B

import { describe, test as it } from "node:test";
import { expect } from "expect";
import { serializeHeaders, unserializeHeaders } from "./headers.js";
describe("headers", () => {
it("serializeHeaders", () => {
const headers = new Headers();
headers.append("X-Test", "1");
headers.append("set-cookie", "a");
headers.append("set-cookie", "b");
const serialized = serializeHeaders(headers);
expect(serialized).toMatchObject({
"x-test": "1",
"set-cookie": ["a", "b"],
});
});
it("unserializeHeaders", () => {
const serialized = {
"x-test": "1",
"set-cookie": ["a", "b"],
};
const headers = unserializeHeaders(serialized);
expect(headers.get("x-test")).toBe("1");
expect(headers.getSetCookie()).toEqual(["a", "b"]);
});
});