test(plugin-sdk): align debouncer runtime mock

This commit is contained in:
Vincent Koc
2026-05-18 14:34:07 +08:00
committed by GitHub
parent 2696f2576d
commit fb70de8046
2 changed files with 17 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
import { createPluginRuntimeMock } from "openclaw/plugin-sdk/channel-test-helpers";
import { describe, expect, it, vi } from "vitest";
describe("createPluginRuntimeMock", () => {
it("keeps the inbound debouncer mock aligned with the runtime contract", () => {
const runtime = createPluginRuntimeMock();
const debouncer = runtime.channel.debounce.createInboundDebouncer({
debounceMs: 0,
buildKey: () => "key",
onFlush: vi.fn(),
});
expect(debouncer.cancelKey("key")).toBe(false);
expect(vi.isMockFunction(debouncer.cancelKey)).toBe(true);
});
});

View File

@@ -605,6 +605,7 @@ export function createPluginRuntimeMock(overrides: DeepPartial<PluginRuntime> =
await params.onFlush([item]);
},
flushKey: vi.fn(),
cancelKey: vi.fn(() => false),
}),
) as unknown as PluginRuntime["channel"]["debounce"]["createInboundDebouncer"],
resolveInboundDebounceMs: vi.fn((params: unknown) => {