37 lines
1.0 KiB
TypeScript
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)
|
|
})
|
|
})
|