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