first commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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"],
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user