Files
familienarchiv/frontend/src/lib/person/genealogy/layout/tidyTree.test.ts
Marcel 13a0d65841 feat(stammbaum): add tidyTree contour packer with leaf base case (#724)
New domain-agnostic bottom-up tidy-tree module (Reingold-Tilford contour pack)
operating on abstract { id, width, children } nodes — zero generated-API
imports. First rung of the TDD ladder: a single leaf lays out at x=0. The full
contour/centring machinery is in place; subsequent commits add tests that
exercise it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 12:57:38 +02:00

20 lines
573 B
TypeScript

import { describe, it, expect } from 'vitest';
import { layoutForest, type TidyNode } from './tidyTree';
// tidyTree is domain-agnostic: it lays out abstract { id, width, children }
// nodes, so these tests use hand-built trees with no PersonNodeDTO import.
const W = 160;
const GAP = 40;
function leaf(id: string, width = W): TidyNode {
return { id, width, children: [] };
}
describe('tidyTree — leaf base case', () => {
it('a single leaf lays out at x = 0', () => {
const a = leaf('a');
const x = layoutForest([a], GAP);
expect(x.get('a')).toBe(0);
});
});