Files
oh-my-pi/packages/coding-agent/test/slash-commands/move.test.ts
T
can1357 6fc29d9643 test(coding-agent): extended test harnesses and modernize async patterns
- Update `acp-builtins.test.ts` to support interactive session movement and path session file testing.
- Clarify `/move` command routing in `/move` slash command tests.
- Rename internal `search` references to `grep` to align with product definitions.
- Refactor TUI render tests to use `Promise.withResolvers` for cleaner flow control.
2026-06-27 04:38:43 +02:00

47 lines
1.5 KiB
TypeScript

import { describe, expect, it, vi } from "bun:test";
import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types";
import { executeBuiltinSlashCommand } from "@oh-my-pi/pi-coding-agent/slash-commands/builtin-registry";
function createRuntime() {
const handleMoveCommand = vi.fn(async () => {});
const showError = vi.fn();
const setText = vi.fn();
const addToHistory = vi.fn();
return {
handleMoveCommand,
showError,
setText,
addToHistory,
runtime: {
ctx: {
editor: { setText, addToHistory } as unknown as InteractiveModeContext["editor"],
showError,
handleMoveCommand,
} as unknown as InteractiveModeContext,
},
};
}
describe("/move slash command", () => {
it("routes the path through the move handler and saves the full command to history", async () => {
const harness = createRuntime();
const handled = await executeBuiltinSlashCommand("/move /tmp/project", harness.runtime);
expect(handled).toBe(true);
expect(harness.setText).toHaveBeenCalledWith("");
expect(harness.handleMoveCommand).toHaveBeenCalledWith("/tmp/project");
});
it("routes a blank /move invocation to the interactive move handler", async () => {
const harness = createRuntime();
const handled = await executeBuiltinSlashCommand("/move ", harness.runtime);
expect(handled).toBe(true);
expect(harness.showError).not.toHaveBeenCalled();
expect(harness.setText).toHaveBeenCalledWith("");
expect(harness.handleMoveCommand).toHaveBeenCalledWith(undefined);
});
});