27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
import assert from "node:assert/strict"
|
|
import { describe, it } from "node:test"
|
|
import { clampPageMarginPx } from "./docs-ruler-margin-math.ts"
|
|
|
|
describe("docs-ruler-margin-math", () => {
|
|
const pageWidth = 794
|
|
const pageHeight = 1122
|
|
const margins = { top: 96, right: 96, bottom: 96, left: 96 }
|
|
|
|
it("clamps left margin against right margin and min body", () => {
|
|
assert.equal(clampPageMarginPx("left", 400, margins, pageWidth, pageHeight), 400)
|
|
assert.equal(clampPageMarginPx("left", 700, margins, pageWidth, pageHeight), 650)
|
|
assert.equal(clampPageMarginPx("left", 0, margins, pageWidth, pageHeight), 12)
|
|
})
|
|
|
|
it("clamps right margin from pointer position", () => {
|
|
assert.equal(clampPageMarginPx("right", 120, margins, pageWidth, pageHeight), 120)
|
|
assert.equal(clampPageMarginPx("right", 700, margins, pageWidth, pageHeight), 650)
|
|
})
|
|
|
|
it("clamps top and bottom margins", () => {
|
|
assert.equal(clampPageMarginPx("top", 48, margins, pageWidth, pageHeight), 48)
|
|
assert.equal(clampPageMarginPx("bottom", 80, margins, pageWidth, pageHeight), 80)
|
|
assert.equal(clampPageMarginPx("top", 900, margins, pageWidth, pageHeight), 978)
|
|
})
|
|
})
|