TableGuard, BottomSpacer, FirstPageHeader and PageChrome implement the verified pagination rules; renderCore returns bytes, a normalised layout tree, audit issues and a layout fingerprint. auditLayout detects overlaps, ink overflow, truncation, header-only pages and split blocks. Quirk tests pin the react-pdf behaviours the design depends on, and a child-process test pins the page-level absolute Svg hang.
21 lines
980 B
TypeScript
21 lines
980 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { chromeHeight } from "./metrics";
|
|
|
|
describe("chromeHeight", () => {
|
|
it("is ceil((ascent - descent + lineGap) / upm * size) + 1 from the manifest", () => {
|
|
// Plex: 1025 + 275 = 1300 / 1000 = 1.3 em
|
|
expect(chromeHeight({ face: "IBM Plex Sans", weight: 400, size: 8 })).toBe(Math.ceil(10.4) + 1);
|
|
expect(chromeHeight("footer")).toBe(Math.ceil(9.75) + 1);
|
|
expect(chromeHeight({ face: "IBM Plex Sans", weight: 400, size: 10 })).toBe(14);
|
|
});
|
|
|
|
it("covers the line react-pdf draws for render-prop text", () => {
|
|
// A 8 pt Plex line is 10.4 pt tall (verified in the layout tree); the reserve must be at least that.
|
|
expect(chromeHeight({ face: "IBM Plex Sans", weight: 400, size: 8 })).toBeGreaterThanOrEqual(10.4);
|
|
});
|
|
|
|
it("falls back across weights and styles instead of failing", () => {
|
|
expect(chromeHeight({ face: "IBM Plex Sans", weight: 600, italic: true, size: 8 })).toBe(12);
|
|
});
|
|
});
|