Files
OpenFrontIO/tests/server/StaticAssetCache.test.ts
T
2026-03-22 20:38:43 +01:00

22 lines
781 B
TypeScript

import { describe, expect, test } from "vitest";
import { getStaticAssetCacheControl } from "../../src/server/StaticAssetCache";
describe("StaticAssetCache", () => {
test("marks Vite asset namespace as immutable", () => {
expect(getStaticAssetCacheControl("/assets/index-abc123.js")).toBe(
"public, max-age=31536000, immutable",
);
});
test("marks custom hashed asset namespace as immutable", () => {
expect(
getStaticAssetCacheControl("/_assets/maps/world/manifest.hash.json"),
).toBe("public, max-age=31536000, immutable");
});
test("does not mark other paths as immutable", () => {
expect(getStaticAssetCacheControl("/manifest.json")).toBeUndefined();
expect(getStaticAssetCacheControl("/api/health")).toBeUndefined();
});
});