test(commands): cover viewport command flow
This commit is contained in:
18
commands/dispatcher.test.ts
Normal file
18
commands/dispatcher.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { createInitialAppState } from "@editor/initial-state";
|
||||
import { createAppStore } from "@editor/store";
|
||||
import { createCommandRegistry } from "./registry";
|
||||
import { viewportPanCommand } from "./viewport";
|
||||
|
||||
describe("command dispatcher", () => {
|
||||
test("throws for unknown commands", () => {
|
||||
const store = createAppStore(createInitialAppState("Test"), createCommandRegistry([]));
|
||||
expect(() => store.dispatch("missing", undefined)).toThrow("Unknown command: missing");
|
||||
});
|
||||
|
||||
test("dispatch applies command result to store", () => {
|
||||
const store = createAppStore(createInitialAppState("Test"), createCommandRegistry([viewportPanCommand]));
|
||||
store.dispatch("viewport.pan", { delta: { x: 3, y: 7 } });
|
||||
expect(store.getState().editor.viewport.center).toEqual({ x: 3, y: 7 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user