Files

21 lines
727 B
TypeScript

import { describe, expect, it } from "vitest";
import { setServerTimingHeaders } from "./defaultHeaders";
describe("default route headers", () => {
it("carries the request nonce and root CSP through nested route header functions", () => {
const nonce = "aBcDeFgHiJkLmNoPqRsTuVwX";
const policy = `default-src 'self'; script-src 'nonce-${nonce}'`;
const headers = setServerTimingHeaders(new Headers(), {
loaderHeaders: new Headers(),
parentHeaders: new Headers({
"x-hivegrid-csp-nonce": nonce,
"Content-Security-Policy": policy,
}),
});
expect(headers.get("x-hivegrid-csp-nonce")).toBe(nonce);
expect(headers.get("Content-Security-Policy")).toBe(policy);
});
});