feat: add safe project upgrades and production performance fixes
This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user