feat: add safe project upgrades and production performance fixes

This commit is contained in:
2026-07-12 16:54:22 +05:30
parent a524c08126
commit 935b3103dd
68 changed files with 555 additions and 107 deletions
+11 -1
View File
@@ -1,5 +1,5 @@
import { expect, test } from "bun:test";
import { fontCspSources, renderFontHead } from "../src/index.ts";
import { fontCspSources, renderFontHead, renderProductionFontHead } from "../src/index.ts";
test("renders subsetted Google and escaped local font markup", () => {
const html = renderFontHead({
@@ -20,3 +20,13 @@ test("renders subsetted Google and escaped local font markup", () => {
font: ["https://fonts.gstatic.com"],
});
});
test("production font head inlines Google CSS and removes its blocking stylesheet", async () => {
const html = await renderProductionFontHead(
{ google: [{ family: "Plus Jakarta Sans", weights: [400, 700] }] },
() => Promise.resolve(new Response('@font-face{font-family:"Plus Jakarta Sans"}')),
);
expect(html).toContain("data-wrnexus-google-fonts");
expect(html).toContain("@font-face");
expect(html).not.toContain('<link rel="stylesheet" href="https://fonts.googleapis.com');
});