// The hive UI's tab routing and menu entries. Run by `npm test`. import assert from "node:assert/strict"; import { test } from "node:test"; import { TABS, menuLinks, tabOfHash } from "../src/shell-routes.js"; test("a hash that names a tab shows that tab, with or without the #", () => { assert.equal(tabOfHash("#rebuild"), "rebuild"); assert.equal(tabOfHash("kept"), "kept"); assert.equal(tabOfHash("#agents"), "agents"); }); test("no hash, or one that names no tab, shows the first tab", () => { assert.equal(tabOfHash(""), TABS[0].href); assert.equal(tabOfHash("#"), TABS[0].href); assert.equal(tabOfHash("#nope"), TABS[0].href); }); test("the API docs are always linked and open in place", () => { assert.deepEqual(menuLinks(null), [ { icon: "🧬", label: "api docs", url: "/api/docs/", external: false }, ]); }); test("the swarm is linked only when the state names its address", () => { assert.equal(menuLinks({}).length, 1); const links = menuLinks({ swarm_public_url: "https://swarm.example" }); assert.equal(links.length, 2); assert.equal(links[1].url, "https://swarm.example"); });