mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 21:25:16 +00:00
test: share process platform spy helper
This commit is contained in:
@@ -40,13 +40,17 @@ export function withRestoredMocks<T>(
|
||||
}
|
||||
}
|
||||
|
||||
export function mockProcessPlatform(platform: NodeJS.Platform): RestorableMock {
|
||||
return vi.spyOn(process, "platform", "get").mockReturnValue(platform);
|
||||
}
|
||||
|
||||
export function withMockedPlatform<T>(platform: NodeJS.Platform, run: () => Promise<T>): Promise<T>;
|
||||
export function withMockedPlatform<T>(platform: NodeJS.Platform, run: () => T): T;
|
||||
export function withMockedPlatform<T>(
|
||||
platform: NodeJS.Platform,
|
||||
run: () => T | Promise<T>,
|
||||
): T | Promise<T> {
|
||||
return withRestoredMocks([vi.spyOn(process, "platform", "get").mockReturnValue(platform)], run);
|
||||
return withRestoredMocks([mockProcessPlatform(platform)], run);
|
||||
}
|
||||
|
||||
export function withMockedWindowsPlatform<T>(run: () => Promise<T>): Promise<T>;
|
||||
|
||||
Reference in New Issue
Block a user