ultisuite-client/lib/drive/docs-page-metrics.test.ts
R3D347HR4Y 2a7c153748
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
wrap page
2026-06-10 12:48:27 +02:00

37 lines
1.0 KiB
TypeScript

import assert from "node:assert/strict"
import { describe, it } from "node:test"
import {
computePageCount,
computePageMetrics,
computeProseMinHeight,
computeStackHeight,
} from "./docs-page-metrics.ts"
describe("docs-page-metrics", () => {
const metrics = computePageMetrics({
widthPx: 794,
heightPx: 1122,
marginsPx: { top: 96, right: 96, bottom: 96, left: 96 },
headerMarginMm: 12.7,
footerMarginMm: 12.7,
})
it("computes body area height from margins", () => {
assert.equal(metrics.bodyAreaHeight, 1122 - 96 - 96)
})
it("computes page count from content height", () => {
assert.equal(computePageCount(400, metrics), 1)
assert.equal(computePageCount(metrics.bodyAreaHeight + 1, metrics), 2)
})
it("computes stack height with page gaps", () => {
assert.equal(computeStackHeight(2, 1122), 1122 * 2 + 12)
})
it("computes prose min height with inter-page spacers", () => {
const minH = computeProseMinHeight(2, metrics)
assert.equal(minH, metrics.bodyAreaHeight * 2 + metrics.interPageSpacer)
})
})