mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-25 00:33:04 +00:00
test(plugin-sdk): align debouncer runtime mock
This commit is contained in:
16
src/plugin-sdk/test-helpers/plugin-runtime-mock.test.ts
Normal file
16
src/plugin-sdk/test-helpers/plugin-runtime-mock.test.ts
Normal 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);
|
||||
});
|
||||
});
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user