ultisuite-client/lib/drive/docs-line-spacing.test.ts
R3D347HR4Y 303b2b1074
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
wow
2026-06-11 01:22:40 +02:00

38 lines
1.0 KiB
TypeScript

import assert from "node:assert/strict"
import { describe, it } from "node:test"
import {
buildParagraphSpacingStyle,
DOCS_LINE_HEIGHT_PRESETS,
lineHeightPresetId,
parseSpacingPt,
} from "./docs-line-spacing.ts"
describe("docs-line-spacing", () => {
it("maps preset ids", () => {
assert.equal(lineHeightPresetId(1.15), "1.15")
assert.equal(lineHeightPresetId(1.3), "custom")
assert.equal(lineHeightPresetId(null), null)
})
it("parses spacing pt", () => {
assert.equal(parseSpacingPt("12"), 12)
assert.equal(parseSpacingPt("-1"), 0)
})
it("builds spacing style", () => {
const style = buildParagraphSpacingStyle({
lineHeight: DOCS_LINE_HEIGHT_PRESETS[1].value,
spaceBeforePt: 12,
spaceAfterPt: 0,
keepWithNext: true,
keepLinesTogether: false,
preventWidowOrphan: true,
pageBreakBefore: false,
})
assert.match(style, /line-height: 1\.15/)
assert.match(style, /margin-top: 12pt/)
assert.match(style, /break-after: avoid/)
assert.match(style, /orphans: 2/)
})
})