mirror of https://github.com/openclaw/openclaw.git
29 lines
893 B
TypeScript
29 lines
893 B
TypeScript
import { vi } from "vitest";
|
|
import type { WizardPrompter } from "../../src/wizard/prompts.js";
|
|
|
|
export type { WizardPrompter } from "../../src/wizard/prompts.js";
|
|
|
|
export async function selectFirstWizardOption<T>(params: {
|
|
options: Array<{ value: T }>;
|
|
}): Promise<T> {
|
|
const first = params.options[0];
|
|
if (!first) {
|
|
throw new Error("no options");
|
|
}
|
|
return first.value;
|
|
}
|
|
|
|
export function createTestWizardPrompter(overrides: Partial<WizardPrompter> = {}): WizardPrompter {
|
|
return {
|
|
intro: vi.fn(async () => {}),
|
|
outro: vi.fn(async () => {}),
|
|
note: vi.fn(async () => {}),
|
|
select: selectFirstWizardOption as WizardPrompter["select"],
|
|
multiselect: vi.fn(async () => []),
|
|
text: vi.fn(async () => "") as WizardPrompter["text"],
|
|
confirm: vi.fn(async () => false),
|
|
progress: vi.fn(() => ({ update: vi.fn(), stop: vi.fn() })),
|
|
...overrides,
|
|
};
|
|
}
|