gram/packages/renderer/tests/print-tokens.test.ts
abiwab dc6899dc12
All checks were successful
CI / Build, Test & Publish (push) Successful in 3m57s
feat(renderer): modernize HTML recipe view layout and intermediate traceability (#126)
2026-11-11 16:02:27 +01:00

20 lines
872 B
TypeScript

import { describe, expect, it } from "bun:test";
import printBase from "../src/shared/print.css" with { type: "text" };
import tokens from "../src/shared/tokens.css" with { type: "text" };
// A view printed like its screen version (the recipe, the run sheet) is set
// in the fonts of the screen: the print base declares the same tokens, with
// the same values, since the screen stylesheet is not on the printed page.
function token(css: string, name: string): string | undefined {
const value = css.match(new RegExp(`${name}:\\s*([^;]+);`))?.[1];
return value?.replace(/\s+/g, " ").trim();
}
describe("print fonts", () => {
for (const name of ["--gram-font-sans", "--gram-font-mono"]) {
it(`${name} is the same on paper as on screen`, () => {
expect(token(tokens, name)).toBeDefined();
expect(token(printBase, name)).toBe(token(tokens, name));
});
}
});