openpencil/tests/engine/kiwi/serialize-fixes/borders/take-space.test.ts
Danila Poyarkov 1ed7de6056 chore(lint): reject broad unknown type assertions
- Add AST-based lint checks for broad unknown object assertions and local JsonObject aliases
- Centralize JsonObject in core and package-local MCP RPC JSON typing
- Replace baseline Record<string, unknown> assertions with named shared/domain types
2026-05-25 00:26:02 +03:00

61 lines
1.7 KiB
TypeScript

import { describe, expect, test } from 'bun:test'
import { SceneGraph } from '@open-pencil/core'
import { pageId, toKiwi } from '../helpers'
describe('Fix 3: bordersTakeSpace serialization', () => {
test('auto-layout frame with strokesIncludedInLayout=true gets bordersTakeSpace=true', () => {
const graph = new SceneGraph()
const node = graph.createNode('FRAME', pageId(graph), {
name: 'LayoutWithBorders',
x: 0,
y: 0,
width: 300,
height: 200,
layoutMode: 'VERTICAL',
itemSpacing: 8,
strokesIncludedInLayout: true
})
const changes = toKiwi(node, graph)
expect(changes[0].bordersTakeSpace).toBe(true)
})
test('auto-layout frame with strokesIncludedInLayout=false gets bordersTakeSpace=false', () => {
const graph = new SceneGraph()
const node = graph.createNode('FRAME', pageId(graph), {
name: 'LayoutNoBorders',
x: 0,
y: 0,
width: 300,
height: 200,
layoutMode: 'VERTICAL',
itemSpacing: 8,
strokesIncludedInLayout: false
})
const changes = toKiwi(node, graph)
expect(changes[0].bordersTakeSpace).toBe(false)
})
test('non-auto-layout frame does not get bordersTakeSpace', () => {
const graph = new SceneGraph()
const node = graph.createNode('FRAME', pageId(graph), {
name: 'PlainFrame',
x: 0,
y: 0,
width: 300,
height: 200,
strokesIncludedInLayout: true
})
const changes = toKiwi(node, graph)
expect(changes[0].bordersTakeSpace).toBeUndefined()
})
})
// ---------------------------------------------------------------------------
// Fix 4 — lineHeight always written on text nodes
// ---------------------------------------------------------------------------