test(plugin-sdk): align debouncer runtime mock · openclaw/openclaw@fb70de8
vincentkoc
·
2026-05-18
·
via Recent Commits to openclaw:main
File tree
src/plugin-sdk/test-helpers
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { createPluginRuntimeMock } from "openclaw/plugin-sdk/channel-test-helpers"; |
| 2 | +import { describe, expect, it, vi } from "vitest"; |
| 3 | + |
| 4 | +describe("createPluginRuntimeMock", () => { |
| 5 | +it("keeps the inbound debouncer mock aligned with the runtime contract", () => { |
| 6 | +const runtime = createPluginRuntimeMock(); |
| 7 | +const debouncer = runtime.channel.debounce.createInboundDebouncer({ |
| 8 | +debounceMs: 0, |
| 9 | +buildKey: () => "key", |
| 10 | +onFlush: vi.fn(), |
| 11 | +}); |
| 12 | + |
| 13 | +expect(debouncer.cancelKey("key")).toBe(false); |
| 14 | +expect(vi.isMockFunction(debouncer.cancelKey)).toBe(true); |
| 15 | +}); |
| 16 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -605,6 +605,7 @@ export function createPluginRuntimeMock(overrides: DeepPartial<PluginRuntime> =
|
605 | 605 | await params.onFlush([item]); |
606 | 606 | }, |
607 | 607 | flushKey: vi.fn(), |
| 608 | +cancelKey: vi.fn(() => false), |
608 | 609 | }), |
609 | 610 | ) as unknown as PluginRuntime["channel"]["debounce"]["createInboundDebouncer"], |
610 | 611 | resolveInboundDebounceMs: vi.fn((params: unknown) => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。