← Files BranchaARCHIVED FILE
skills/brancha/app/src/ui/lib/layout.test.ts
791 Bytes · Oct 5, 2026 · 18:29 UTC
import test from 'node:test';
import assert from 'node:assert/strict';
import { layoutTree } from './layout';
import type { TreeNode } from '../types';
const node = (id: string, parent_id: string | null): TreeNode => ({
id, seq: 1, parent_id, project_id: 'p', position: 0,
type: parent_id ? 'html' : 'text', title: id, content: parent_id ? `${id}.html` : null,
artifact_revision: '', created_at: '2026-01-01', updated_at: '2026-01-01',
});
test('tree layout moves children right and centers their parent', () => {
const positions = layoutTree([node('root', null), node('a', 'root'), node('b', 'root')]);
const root = positions.get('root')!, a = positions.get('a')!, b = positions.get('b')!;
assert.ok(a.x > root.x && b.x > root.x);
assert.equal(root.y, (a.y + b.y) / 2);
});
SHA-256: d7d75795913cbd01858da014b48d9b32372dcf5a92fdbbce18d2e9ca05bf6df1