mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { collectPresentOpenClawTools } from "./openclaw-tools.registration.js";
|
|
import { textResult, type AnyAgentTool } from "./tools/common.js";
|
|
|
|
function stubAgentTool(name: string): AnyAgentTool {
|
|
return {
|
|
label: name,
|
|
name,
|
|
description: `${name} stub`,
|
|
parameters: { type: "object", properties: {} },
|
|
async execute() {
|
|
return textResult("ok", {});
|
|
},
|
|
};
|
|
}
|
|
|
|
export function describeOpenClawGenerationToolRegistration(params: {
|
|
suiteName: string;
|
|
toolName: string;
|
|
toolLabel: string;
|
|
}) {
|
|
describe(params.suiteName, () => {
|
|
it(`registers ${params.toolName} when ${params.toolLabel} is present`, () => {
|
|
const tool = stubAgentTool(params.toolName);
|
|
|
|
expect(collectPresentOpenClawTools([tool])).toEqual([tool]);
|
|
});
|
|
|
|
it(`omits ${params.toolName} when ${params.toolLabel} is absent`, () => {
|
|
expect(collectPresentOpenClawTools([null]).map((tool) => tool.name)).not.toContain(
|
|
params.toolName,
|
|
);
|
|
});
|
|
});
|
|
}
|