mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 09:30:22 +00:00
refactor(nodes): dedupe camera payload and node resolve helpers
This commit is contained in:
21
src/test-utils/camera-url-test-helpers.ts
Normal file
21
src/test-utils/camera-url-test-helpers.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import * as fs from "node:fs/promises";
|
||||
import { vi } from "vitest";
|
||||
|
||||
export function stubFetchResponse(response: Response) {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn(async () => response),
|
||||
);
|
||||
}
|
||||
|
||||
export function stubFetchTextResponse(text: string, init?: ResponseInit) {
|
||||
stubFetchResponse(new Response(text, { status: 200, ...init }));
|
||||
}
|
||||
|
||||
export async function readFileUtf8AndCleanup(filePath: string): Promise<string> {
|
||||
try {
|
||||
return await fs.readFile(filePath, "utf8");
|
||||
} finally {
|
||||
await fs.unlink(filePath).catch(() => {});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user