mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-29 19:01:44 +00:00
test: make media runtime seam mock bun-safe
This commit is contained in:
@@ -5,27 +5,27 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { createEmptyPluginRegistry } from "../plugins/registry.js";
|
||||
|
||||
const { resolveRuntimePluginRegistryMock } = vi.hoisted(() => ({
|
||||
resolveRuntimePluginRegistryMock: vi.fn<
|
||||
(params?: unknown) => ReturnType<typeof createEmptyPluginRegistry> | undefined
|
||||
>(() => undefined),
|
||||
}));
|
||||
|
||||
vi.mock("../plugins/loader.js", () => ({
|
||||
resolveRuntimePluginRegistry: resolveRuntimePluginRegistryMock,
|
||||
}));
|
||||
|
||||
let describeImageFile: typeof import("./runtime.js").describeImageFile;
|
||||
let runMediaUnderstandingFile: typeof import("./runtime.js").runMediaUnderstandingFile;
|
||||
let resolveRuntimePluginRegistryMock: ReturnType<
|
||||
typeof vi.fn<(params?: unknown) => ReturnType<typeof createEmptyPluginRegistry> | undefined>
|
||||
>;
|
||||
|
||||
describe("media-understanding runtime helpers", () => {
|
||||
afterEach(() => {
|
||||
resolveRuntimePluginRegistryMock.mockReset();
|
||||
resolveRuntimePluginRegistryMock.mockReturnValue(undefined);
|
||||
vi.doUnmock("../plugins/loader.js");
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
resolveRuntimePluginRegistryMock = vi.fn<
|
||||
(params?: unknown) => ReturnType<typeof createEmptyPluginRegistry> | undefined
|
||||
>(() => undefined);
|
||||
vi.doMock("../plugins/loader.js", () => ({
|
||||
resolveRuntimePluginRegistry: resolveRuntimePluginRegistryMock,
|
||||
}));
|
||||
({ describeImageFile, runMediaUnderstandingFile } = await import("./runtime.js"));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user