mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 18:04:45 +00:00
test: guard skill workshop mock calls
This commit is contained in:
@@ -72,8 +72,16 @@ function detailRecord(result: unknown): Record<string, unknown> {
|
||||
return details as Record<string, unknown>;
|
||||
}
|
||||
|
||||
function mockCall(mock: { mock: { calls: unknown[][] } }, index: number, label: string) {
|
||||
const call = mock.mock.calls[index];
|
||||
if (!call) {
|
||||
throw new Error(`expected ${label}`);
|
||||
}
|
||||
return call;
|
||||
}
|
||||
|
||||
function firstMockArg(mock: { mock: { calls: unknown[][] } }): Record<string, unknown> {
|
||||
const arg = mock.mock.calls[0]?.[0];
|
||||
const arg = mockCall(mock, 0, "first mock call")[0];
|
||||
if (!arg || typeof arg !== "object" || Array.isArray(arg)) {
|
||||
throw new Error("expected first mock argument object");
|
||||
}
|
||||
@@ -106,8 +114,8 @@ describe("skill-workshop", () => {
|
||||
|
||||
expect(tool).toBeNull();
|
||||
expect(on.mock.calls.map(([hook]) => hook)).toEqual(["before_prompt_build", "agent_end"]);
|
||||
expect(typeof on.mock.calls[0]?.[1]).toBe("function");
|
||||
expect(typeof on.mock.calls[1]?.[1]).toBe("function");
|
||||
expect(typeof mockCall(on, 0, "before_prompt_build hook registration")[1]).toBe("function");
|
||||
expect(typeof mockCall(on, 1, "agent_end hook registration")[1]).toBe("function");
|
||||
});
|
||||
|
||||
it("detects user corrections and creates an animated GIF proposal", async () => {
|
||||
|
||||
Reference in New Issue
Block a user