mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-03 03:03:24 -04:00
chore: Fix types in tests 23/N.
This commit is contained in:
@@ -104,7 +104,17 @@ describe("after_tool_call hook wiring", () => {
|
||||
expect(hookMocks.runner.runAfterToolCall).toHaveBeenCalledTimes(1);
|
||||
expect(hookMocks.runner.runBeforeToolCall).not.toHaveBeenCalled();
|
||||
|
||||
const [event, context] = hookMocks.runner.runAfterToolCall.mock.calls[0];
|
||||
const firstCall = (hookMocks.runner.runAfterToolCall as ReturnType<typeof vi.fn>).mock.calls[0];
|
||||
expect(firstCall).toBeDefined();
|
||||
const event = firstCall?.[0] as
|
||||
| { toolName?: string; params?: unknown; error?: unknown; durationMs?: unknown }
|
||||
| undefined;
|
||||
const context = firstCall?.[1] as { toolName?: string } | undefined;
|
||||
expect(event).toBeDefined();
|
||||
expect(context).toBeDefined();
|
||||
if (!event || !context) {
|
||||
throw new Error("missing hook call payload");
|
||||
}
|
||||
expect(event.toolName).toBe("read");
|
||||
expect(event.params).toEqual({ path: "/tmp/file.txt" });
|
||||
expect(event.error).toBeUndefined();
|
||||
@@ -143,7 +153,13 @@ describe("after_tool_call hook wiring", () => {
|
||||
|
||||
expect(hookMocks.runner.runAfterToolCall).toHaveBeenCalledTimes(1);
|
||||
|
||||
const [event] = hookMocks.runner.runAfterToolCall.mock.calls[0];
|
||||
const firstCall = (hookMocks.runner.runAfterToolCall as ReturnType<typeof vi.fn>).mock.calls[0];
|
||||
expect(firstCall).toBeDefined();
|
||||
const event = firstCall?.[0] as { error?: unknown } | undefined;
|
||||
expect(event).toBeDefined();
|
||||
if (!event) {
|
||||
throw new Error("missing hook call payload");
|
||||
}
|
||||
expect(event.error).toBeDefined();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user