mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
test: drop duplicate internal hook lifecycle case
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
||||
triggerInternalHook,
|
||||
unregisterInternalHook,
|
||||
type AgentBootstrapHookContext,
|
||||
type InternalHookEvent,
|
||||
} from "./internal-hooks.js";
|
||||
|
||||
describe("hooks", () => {
|
||||
@@ -211,37 +210,4 @@ describe("hooks", () => {
|
||||
expect(keys).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("integration", () => {
|
||||
it("should handle a complete hook lifecycle", async () => {
|
||||
const results: InternalHookEvent[] = [];
|
||||
const handler = vi.fn((event: InternalHookEvent) => {
|
||||
results.push(event);
|
||||
});
|
||||
|
||||
// Register
|
||||
registerInternalHook("command:new", handler);
|
||||
|
||||
// Trigger
|
||||
const event1 = createInternalHookEvent("command", "new", "session-1");
|
||||
await triggerInternalHook(event1);
|
||||
|
||||
const event2 = createInternalHookEvent("command", "new", "session-2");
|
||||
await triggerInternalHook(event2);
|
||||
|
||||
// Verify
|
||||
expect(results).toHaveLength(2);
|
||||
expect(results[0].sessionKey).toBe("session-1");
|
||||
expect(results[1].sessionKey).toBe("session-2");
|
||||
|
||||
// Unregister
|
||||
unregisterInternalHook("command:new", handler);
|
||||
|
||||
// Trigger again - should not call handler
|
||||
const event3 = createInternalHookEvent("command", "new", "session-3");
|
||||
await triggerInternalHook(event3);
|
||||
|
||||
expect(results).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user