fix: dock final review — shared state, menu guards, cleanup
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
fa44ec0bf7
commit
989fa88345
4 files changed
+103
-47
No files matched your search
+10
-1
@@ -2,7 +2,7 @@ import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import {
|
||||
DOCK_LIMIT, LABEL_MAX, defaultLabel, normalize, isPinned, pin, unpin, remove, move,
|
||||
rename, toggleMode, dockAction, dockMenu, rowMenu, starMenu, menuTransition,
|
||||
rename, toggleMode, dockAction, dockMenu, rowMenu, starMenu, menuTransition, applyDock,
|
||||
} from "../herdr/herdr-composer/mods/herdr-composer/dock.js";
|
||||
|
||||
const btn = (id, text, extra = {}) => ({ id, label: text, text, mode: "send", ...extra });
|
||||
@@ -149,3 +149,12 @@ test("menuTransition: open replaces, close only closes its own menu", () => {
|
||||
// same id, other kind is another menu
|
||||
assert.deepEqual(menuTransition(B, { kind: "star", id: "B", open: false }), B);
|
||||
});
|
||||
|
||||
test("applyDock: works on the stored list, so another copy's change survives", () => {
|
||||
const stored = [btn("1", "a"), btn("2", "from-copy-A")];
|
||||
// copy B held only ["a"]; it pins "b" - the result keeps A's pin
|
||||
const out = applyDock(stored, (d) => pin(d, "b", "3"));
|
||||
assert.deepEqual(out.map((b) => b.id), ["1", "2", "3"]);
|
||||
assert.deepEqual(applyDock("rubbish", (d) => pin(d, "x", "9")).map((b) => b.id), ["9"]);
|
||||
assert.deepEqual(applyDock(stored, (d) => remove(d, "1")).map((b) => b.id), ["2"]);
|
||||
});
|
||||
Reference in new issue
Block a user