20 lines · 676 B
import { describe, expect, mock, test } from "bun:test";

mock.module("cloudflare:workers", () => ({ env: {}, waitUntil: () => undefined }));

const { rawCacheControl } = await import("./raw");

describe("rawCacheControl", () => {
  test("branch and tag paths revalidate", () => {
    expect(rawCacheControl(false, "public")).toBe("no-cache");
  });

  test("public commit-pinned files expire within a day", () => {
    expect(rawCacheControl(true, "public")).toBe("public, max-age=86400");
  });

  test("private commit-pinned files stay in the private cache only", () => {
    expect(rawCacheControl(true, "private")).toBe("private, max-age=31536000, immutable");
  });
});