Group tabs now show the grip and drag like agent tabs, and every tab in the strip takes the place of the tab another one is dropped on; the order is kept with the open tabs. An agent's tab keeps its other drag, onto a terminal to split it. moveTab is a pure function with tests.
26 lines
935 B
JavaScript
26 lines
935 B
JavaScript
// 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");
|
|
});
|