openpencil/tests/engine/scene-graph/layout-guides.test.ts
Danila Poyarkov 9ef2f63d57 fix(editor): harden snapping edge cases
- Preserve rounded auto-layout preview displacement through drop commits
- Bound imported layout-guide counts and tiny grid steps
- Normalize missing guide arrays in direct graph hydration paths
- Add regression coverage for auto-layout movement and guide limits
2026-08-19 12:33:32 +03:00

30 lines
857 B
TypeScript

import { describe, expect, test } from 'bun:test'
import { layoutGuideLines, layoutGuideSections } from '@open-pencil/scene-graph/layout-guides'
describe('layout guide geometry bounds', () => {
test('normalizes fractional section counts', () => {
expect(
layoutGuideSections(
{ width: 100, height: 100 },
{ pattern: 'COLUMNS', count: 2.8, sectionSize: 10 }
)
).toHaveLength(2)
})
test('caps pathological section and grid line counts', () => {
expect(
layoutGuideSections(
{ width: 100, height: 100 },
{ pattern: 'COLUMNS', count: Number.MAX_SAFE_INTEGER, sectionSize: 0.001 }
)
).toHaveLength(10_000)
expect(
layoutGuideLines(
{ width: 100, height: 100 },
{ pattern: 'GRID', sectionSize: Number.MIN_VALUE }
)
).toHaveLength(20_000)
})
})