mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:14:30 +00:00
refactor(tui): dedupe handlers and formatter test setup
This commit is contained in:
32
src/tui/tui-submit-test-helpers.ts
Normal file
32
src/tui/tui-submit-test-helpers.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { vi } from "vitest";
|
||||
import { createEditorSubmitHandler } from "./tui.js";
|
||||
|
||||
type MockFn = ReturnType<typeof vi.fn>;
|
||||
|
||||
export type SubmitHarness = {
|
||||
editor: {
|
||||
setText: MockFn;
|
||||
addToHistory: MockFn;
|
||||
};
|
||||
handleCommand: MockFn;
|
||||
sendMessage: MockFn;
|
||||
handleBangLine: MockFn;
|
||||
onSubmit: (text: string) => void;
|
||||
};
|
||||
|
||||
export function createSubmitHarness(): SubmitHarness {
|
||||
const editor = {
|
||||
setText: vi.fn(),
|
||||
addToHistory: vi.fn(),
|
||||
};
|
||||
const handleCommand = vi.fn();
|
||||
const sendMessage = vi.fn();
|
||||
const handleBangLine = vi.fn();
|
||||
const onSubmit = createEditorSubmitHandler({
|
||||
editor,
|
||||
handleCommand,
|
||||
sendMessage,
|
||||
handleBangLine,
|
||||
});
|
||||
return { editor, handleCommand, sendMessage, handleBangLine, onSubmit };
|
||||
}
|
||||
Reference in New Issue
Block a user