// src/tools/search/glob.test.ts // Copyright (C) 2025 DTP Technologies, LLC // All Rights Reserved import { describe, it, expect, beforeEach } from "vitest"; import GlobTool from "./glob.js"; describe("GlobTool", () => { let tool: typeof GlobTool; let mockSession: any; beforeEach(() => { tool = GlobTool; mockSession = { _id: "test-session-id", user: "test-user-id", }; }); describe("definition", () => { it("should have correct tool name", () => { expect(tool.definition.function.name).toBe("glob"); }); it("should have correct category", () => { expect(tool.metadata.category).toBe("search"); }); it("should support all modes", () => { expect(tool.metadata.modes).toHaveLength(5); }); }); describe("execute", () => { it("should return error for missing pattern", async () => { const result = await tool.execute({ session: mockSession }, {}); expect(result).toContain("MISSING_PARAMETER"); expect(result).toContain("pattern is required"); }); it("should find TypeScript files", async () => { const result = await tool.execute( { session: mockSession }, { pattern: "**/*.ts" }, ); expect(result).toContain("Found"); expect(result).toContain(".ts"); }); it("should respect root parameter", async () => { const result = await tool.execute( { session: mockSession }, { pattern: "*.ts", root: "src" }, ); expect(result).toContain("Found"); }); }); });