mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:50:46 +00:00
test: share gateway dispatch mock exports
This commit is contained in:
@@ -82,6 +82,22 @@ async function importEmbeddedRunMockModule<TModule extends object>(
|
||||
};
|
||||
}
|
||||
|
||||
function createDispatchInboundMessageMockExports(
|
||||
actual: typeof import("../auto-reply/dispatch.js"),
|
||||
): typeof import("../auto-reply/dispatch.js") {
|
||||
return {
|
||||
...actual,
|
||||
dispatchInboundMessage: (...args: Parameters<typeof actual.dispatchInboundMessage>) => {
|
||||
const impl = gatewayTestHoisted.dispatchInboundMessage.getMockImplementation();
|
||||
return impl
|
||||
? (gatewayTestHoisted.dispatchInboundMessage(...args) as ReturnType<
|
||||
typeof actual.dispatchInboundMessage
|
||||
>)
|
||||
: actual.dispatchInboundMessage(...args);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
vi.mock("../agents/pi-model-discovery.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../agents/pi-model-discovery.js")>(
|
||||
"../agents/pi-model-discovery.js",
|
||||
@@ -279,29 +295,13 @@ vi.mock("../auto-reply/dispatch.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../auto-reply/dispatch.js")>(
|
||||
"../auto-reply/dispatch.js",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
dispatchInboundMessage: (...args: Parameters<typeof actual.dispatchInboundMessage>) => {
|
||||
const impl = gatewayTestHoisted.dispatchInboundMessage.getMockImplementation();
|
||||
return impl
|
||||
? gatewayTestHoisted.dispatchInboundMessage(...args)
|
||||
: actual.dispatchInboundMessage(...args);
|
||||
},
|
||||
};
|
||||
return createDispatchInboundMessageMockExports(actual);
|
||||
});
|
||||
vi.mock("/src/auto-reply/dispatch.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../auto-reply/dispatch.js")>(
|
||||
"../auto-reply/dispatch.js",
|
||||
);
|
||||
return {
|
||||
...actual,
|
||||
dispatchInboundMessage: (...args: Parameters<typeof actual.dispatchInboundMessage>) => {
|
||||
const impl = gatewayTestHoisted.dispatchInboundMessage.getMockImplementation();
|
||||
return impl
|
||||
? gatewayTestHoisted.dispatchInboundMessage(...args)
|
||||
: actual.dispatchInboundMessage(...args);
|
||||
},
|
||||
};
|
||||
return createDispatchInboundMessageMockExports(actual);
|
||||
});
|
||||
vi.mock("../auto-reply/reply.js", () => ({
|
||||
getReplyFromConfig: (...args: Parameters<GetReplyFromConfigFn>) =>
|
||||
|
||||
Reference in New Issue
Block a user