Files
RuneStone/tests/unit/layout/splitLayout.spec.ts
T
2026-11-16 04:21:21 -07:00

19 lines
843 B
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { splitPane, removePane, paneBounds, containsPane } from "../../../src/lib/workspace/splitLayout.ts";
test("nested splits preserve the source and divide the requested pane", () => {
const right = splitPane("a", "a", "b", "right");
const nested = splitPane(right, "b", "c", "down");
assert.deepEqual(paneBounds(nested), {
a: { left: 0, top: 0, width: 50, height: 100 },
b: { left: 50, top: 0, width: 50, height: 50 },
c: { left: 50, top: 50, width: 50, height: 50 },
});
assert.equal(containsPane(nested, "c"), true);
const closed = removePane(nested, "b")!;
assert.deepEqual(paneBounds(closed).c, { left: 50, top: 0, width: 50, height: 100 });
assert.equal(removePane(closed, "a"), "c");
assert.equal(removePane("c", "c"), null);
});