20 lines
1003 B
TypeScript
20 lines
1003 B
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { createInitialAppState } from "@editor/initial-state";
|
|
import { toolEnterTemporaryPanCommand, toolExitTemporaryPanCommand, toolSetActiveCommand } from "./tool";
|
|
|
|
describe("tool commands", () => {
|
|
test("sets active tool", () => {
|
|
const next = toolSetActiveCommand.execute({ state: createInitialAppState("Test") }, { tool: "pan" });
|
|
expect(next.editor.tools).toEqual({ activeTool: "pan", interactionMode: { type: "tool", tool: "pan" } });
|
|
});
|
|
|
|
test("enters and exits temporary pan", () => {
|
|
const initial = createInitialAppState("Test");
|
|
const panning = toolEnterTemporaryPanCommand.execute({ state: initial }, undefined);
|
|
const restored = toolExitTemporaryPanCommand.execute({ state: panning }, undefined);
|
|
|
|
expect(panning.editor.tools).toEqual({ activeTool: "select", interactionMode: { type: "temporary-pan", previousTool: "select" } });
|
|
expect(restored.editor.tools).toEqual(initial.editor.tools);
|
|
});
|
|
});
|