feat(stammbaum): bloodline-contiguous tidy-tree layout (replace per-generation packer) (#724) #725
@@ -697,3 +697,27 @@ describe('buildLayout — termination + once-only on cyclic input (#724)', () =>
|
||||
for (const id of [F, A, B, C]) expect(layout.positions.get(id)).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildLayout — degenerate graphs (#724)', () => {
|
||||
it('empty graph yields no positions and the MIN viewBox (no NaN)', () => {
|
||||
// Runs on a fresh /stammbaum visit before any data loads — must not throw
|
||||
// or emit NaN into the SVG viewBox.
|
||||
const layout = buildLayout([], []);
|
||||
expect(layout.positions.size).toBe(0);
|
||||
expect(layout.crossLinks).toEqual([]);
|
||||
expect(layout.generations.size).toBe(0);
|
||||
for (const v of [layout.viewX, layout.viewY, layout.viewW, layout.viewH]) {
|
||||
expect(Number.isFinite(v)).toBe(true);
|
||||
}
|
||||
// computeViewBox falls back to MIN dimensions when there is no content.
|
||||
expect(layout.viewW).toBe(1200);
|
||||
expect(layout.viewH).toBe(800);
|
||||
});
|
||||
|
||||
it('single isolated node is placed once at rank 0', () => {
|
||||
const layout = buildLayout([node(PARENT, 'Solo', 0)], []);
|
||||
expect(layout.positions.size).toBe(1);
|
||||
expect(layout.positions.get(PARENT)).toEqual({ x: 0, y: 0 });
|
||||
expect(layout.crossLinks).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user