- Updated class names for paragraph style and font family select triggers to improve styling consistency. - Added new CSS rules for hover and focus states on select triggers, enhancing user interaction feedback. - Implemented logic to drop trailing empty pages in document metrics calculations, optimizing page count accuracy. - Enhanced tests to verify new page count behavior when content fits within existing layouts.
44 lines
1.4 KiB
TypeScript
44 lines
1.4 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("drops a trailing page when content fits the previous page layout", () => {
|
|
const fourPages = computeProseMinHeight(4, metrics)
|
|
assert.equal(computePageCount(fourPages, metrics), 4)
|
|
assert.equal(computePageCount(fourPages - 1, metrics), 4)
|
|
assert.equal(computePageCount(fourPages + 1, metrics), 5)
|
|
})
|
|
|
|
it("computes stack height with page gaps", () => {
|
|
assert.equal(computeStackHeight(2, 1122), 1122 * 2 + 24)
|
|
})
|
|
|
|
it("computes prose min height with inter-page spacers", () => {
|
|
const minH = computeProseMinHeight(2, metrics)
|
|
assert.equal(minH, metrics.bodyAreaHeight * 2 + metrics.interPageSpacer)
|
|
})
|
|
})
|