feat(commands): add selection commands
This commit is contained in:
25
commands/selection.test.ts
Normal file
25
commands/selection.test.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createInitialAppState } from "@editor/initial-state";
|
||||
import { selectionAddLayerCommand, selectionClearCommand, selectionSetCommand } from "./selection";
|
||||
|
||||
describe("selection commands", () => {
|
||||
test("sets selection", () => {
|
||||
const next = selectionSetCommand.execute({ state: createInitialAppState("Test") }, { artboardId: "a1", layerIds: ["l1"] });
|
||||
expect(next.editor.selection).toEqual({ artboardId: "a1", layerIds: ["l1"] });
|
||||
});
|
||||
|
||||
test("adds unique layer selection", () => {
|
||||
const selected = selectionSetCommand.execute({ state: createInitialAppState("Test") }, { layerIds: ["l1"] });
|
||||
const next = selectionAddLayerCommand.execute({ state: selected }, { layerId: "l2" });
|
||||
const same = selectionAddLayerCommand.execute({ state: next }, { layerId: "l2" });
|
||||
|
||||
expect(next.editor.selection.layerIds).toEqual(["l1", "l2"]);
|
||||
expect(same).toBe(next);
|
||||
});
|
||||
|
||||
test("clears selection", () => {
|
||||
const selected = selectionSetCommand.execute({ state: createInitialAppState("Test") }, { artboardId: "a1", layerIds: ["l1"] });
|
||||
const next = selectionClearCommand.execute({ state: selected }, undefined);
|
||||
expect(next.editor.selection).toEqual({ layerIds: [] });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user