Files
genoffice/apps/docs/tests/page-margins.test.ts
T
merrick-2002andGenOffice dc4d7e5927 Sync snapshot (2026-08-12) (#87)
- Add text insertion and improved text editing in PDF files
- Expand PDF form filling, annotations, highlighting, and visual signature workflows
- Add PDF image crop, flip, transparency, replacement, and background removal
- Improve Sheets validation rendering, undo behavior, and workbook stability
- Add system font discovery and improve shared Office interface consistency
- Improve AI network resilience and response validation

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
2026-08-12 08:36:35 +08:00

30 lines
918 B
TypeScript

import { describe, expect, it } from 'vitest'
import {
cmFromTwips,
marginsFitPage,
twipsFromCmInput,
} from '../src/renderer/components/MarginDialog'
describe('page margins', () => {
it('preserves the original twips when a rounded display value is unchanged', () => {
const moderateMargin = 1080
const displayed = String(cmFromTwips(moderateMargin))
expect(displayed).toBe('1.91')
expect(twipsFromCmInput(displayed, moderateMargin)).toBe(moderateMargin)
})
it('converts an edited centimeter value to twips', () => {
expect(twipsFromCmInput('2', 1080)).toBe(1134)
})
it('rejects margins that do not leave the minimum page body', () => {
expect(marginsFitPage({ top: 720, right: 5000, bottom: 720, left: 5000 }, 10319, 14572)).toBe(
false,
)
expect(marginsFitPage({ top: 720, right: 720, bottom: 720, left: 720 }, 10319, 14572)).toBe(
true,
)
})
})