summaryrefslogtreecommitdiffhomepage
path: root/src/features/layout/logic/panels-edit.test.ts
blob: b4c3099715c04103398e9862719226c911b176ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { describe, expect, it } from "vitest";
import { addPanelOp, firstPanelView, removePanelOp, swapPanelOp } from "./panels-edit";

describe("panel edit → op mapping", () => {
  it("maps a dropdown swap to a replaceView on the panel leaf's path", () => {
    expect(swapPanelOp([1], 2, "model")).toEqual({
      type: "replaceView",
      target: [1, 2],
      view: "model",
    });
  });

  it("maps the + button to an append insertPanel", () => {
    expect(addPanelOp(["titlebar"], "tasks")).toEqual({
      type: "insertPanel",
      panels: ["titlebar"],
      view: "tasks",
    });
  });

  it("maps the ✕ button to a removeNode on the panel leaf's path", () => {
    expect(removePanelOp([1], 0)).toEqual({ type: "removeNode", target: [1, 0] });
  });

  it("the + button pre-selects the first eligible view (or null when none)", () => {
    expect(firstPanelView([{ id: "tabs" }, { id: "model" }])).toBe("tabs");
    expect(firstPanelView([])).toBeNull();
  });
});