refactor: add hook guards and test helpers
This commit is contained in:
@@ -3,9 +3,11 @@ import {
|
||||
clearInternalHooks,
|
||||
createInternalHookEvent,
|
||||
getRegisteredEventKeys,
|
||||
isAgentBootstrapEvent,
|
||||
registerInternalHook,
|
||||
triggerInternalHook,
|
||||
unregisterInternalHook,
|
||||
type AgentBootstrapHookContext,
|
||||
type InternalHookEvent,
|
||||
} from "./internal-hooks.js";
|
||||
|
||||
@@ -164,6 +166,22 @@ describe("hooks", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isAgentBootstrapEvent", () => {
|
||||
it("returns true for agent:bootstrap events with expected context", () => {
|
||||
const context: AgentBootstrapHookContext = {
|
||||
workspaceDir: "/tmp",
|
||||
bootstrapFiles: [],
|
||||
};
|
||||
const event = createInternalHookEvent("agent", "bootstrap", "test-session", context);
|
||||
expect(isAgentBootstrapEvent(event)).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false for non-bootstrap events", () => {
|
||||
const event = createInternalHookEvent("command", "new", "test-session");
|
||||
expect(isAgentBootstrapEvent(event)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getRegisteredEventKeys", () => {
|
||||
it("should return all registered event keys", () => {
|
||||
registerInternalHook("command:new", vi.fn());
|
||||
|
||||
Reference in New Issue
Block a user