23 lines
719 B
TypeScript
23 lines
719 B
TypeScript
import { expect, test } from "bun:test";
|
|
import { fontCspSources, renderFontHead } from "../src/index.ts";
|
|
|
|
test("renders subsetted Google and escaped local font markup", () => {
|
|
const html = renderFontHead({
|
|
google: [{ family: "Inter", weights: [700, 400] }],
|
|
local: [
|
|
{
|
|
family: 'Bad"</style><script>x</script>',
|
|
src: '/font".woff2',
|
|
preload: true,
|
|
},
|
|
],
|
|
});
|
|
expect(html).toContain("family=Inter:wght@400;700");
|
|
expect(html).not.toContain("</style><script>");
|
|
expect(html).toContain(""");
|
|
expect(fontCspSources({ google: [{ family: "Inter" }] })).toEqual({
|
|
style: ["https://fonts.googleapis.com"],
|
|
font: ["https://fonts.gstatic.com"],
|
|
});
|
|
});
|