// The order of the header's dynamic tabs. Run by `npm test`. import assert from "node:assert/strict"; import { test } from "node:test"; import { moveTab } from "../src/shell/tab-order.ts"; const tabs = ["a", "b", "c", "d"].map((href) => ({ href })); const order = (list) => list.map((t) => t.href).join(""); test("a tab moved right takes the place of the tab it lands on", () => { assert.equal(order(moveTab(tabs, "a", "c")), "bcad"); }); test("a tab moved left lands before the tab it is dropped on", () => { assert.equal(order(moveTab(tabs, "d", "b")), "adbc"); }); test("dropping a tab on itself, or naming a tab that is gone, changes nothing", () => { assert.equal(moveTab(tabs, "b", "b"), tabs); assert.equal(moveTab(tabs, "x", "b"), tabs); assert.equal(moveTab(tabs, "b", "x"), tabs); }); test("the list it was given is left as it was", () => { moveTab(tabs, "a", "d"); assert.equal(order(tabs), "abcd"); });