mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-01 10:40:21 +00:00
refactor(test): dedupe setup wizard helpers
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk/testing";
|
||||
import { vi } from "vitest";
|
||||
|
||||
export function createRuntimeEnv(options?: { throwOnExit?: boolean }): RuntimeEnv {
|
||||
export function createRuntimeEnv<TRuntime = RuntimeEnv>(options?: {
|
||||
throwOnExit?: boolean;
|
||||
}): RuntimeEnv {
|
||||
const throwOnExit = options?.throwOnExit ?? true;
|
||||
return {
|
||||
log: vi.fn(),
|
||||
@@ -13,3 +15,15 @@ export function createRuntimeEnv(options?: { throwOnExit?: boolean }): RuntimeEn
|
||||
: vi.fn(),
|
||||
};
|
||||
}
|
||||
|
||||
export function createTypedRuntimeEnv<TRuntime>(options?: { throwOnExit?: boolean }): TRuntime {
|
||||
return createRuntimeEnv(options) as TRuntime;
|
||||
}
|
||||
|
||||
export function createNonExitingRuntimeEnv(): RuntimeEnv {
|
||||
return createRuntimeEnv({ throwOnExit: false });
|
||||
}
|
||||
|
||||
export function createNonExitingTypedRuntimeEnv<TRuntime>(): TRuntime {
|
||||
return createTypedRuntimeEnv<TRuntime>({ throwOnExit: false });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user