import assert from "node:assert/strict"; import test from "node:test"; import { expandHiddenLinks } from "../src/data/model-tree.ts"; test("hiding a link includes every descendant link in its joint subtree", () => { const model = { root: "base", links: Object.fromEntries( ["base", "arm", "elbow", "hand", "camera"].map((name) => [ name, { mesh: name, xyz: [0, 0, 0], rpy: [0, 0, 0] }, ]), ), joints: [ { parent: "base", child: "arm" }, { parent: "arm", child: "elbow" }, { parent: "elbow", child: "hand" }, { parent: "base", child: "camera" }, ], }; assert.deepEqual( new Set(expandHiddenLinks(model, ["arm"])), new Set(["arm", "elbow", "hand"]), ); }); test("unknown links and unrelated roots are not included", () => { const model = { root: "base", links: { base: { mesh: "base", xyz: [0, 0, 0], rpy: [0, 0, 0] }, arm: { mesh: "arm", xyz: [0, 0, 0], rpy: [0, 0, 0] }, leg: { mesh: "leg", xyz: [0, 0, 0], rpy: [0, 0, 0] }, }, joints: [{ parent: "base", child: "arm" }], }; assert.deepEqual(expandHiddenLinks(model, ["missing", "leg"]), ["leg"]); });