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); }); });