search.test.ts•915 B
/** Unit test for searchAction */
import { Command } from "commander";
import { beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("../../store", () => ({
createDocumentManagement: vi.fn(async () => ({ shutdown: vi.fn() })),
}));
vi.mock("../../tools", () => ({
SearchTool: vi
.fn()
.mockImplementation(() => ({ execute: vi.fn(async () => ({ results: [] })) })),
}));
import { searchAction } from "./search";
function _cmd() {
return new Command();
}
beforeEach(() => vi.clearAllMocks());
describe("searchAction", () => {
it("invokes SearchTool with parameters", async () => {
await searchAction("react", "hooks", {
version: "18.x",
limit: "3",
exactMatch: false,
serverUrl: undefined,
embeddingModel: "mock-embedding-model",
});
const { SearchTool } = await import("../../tools");
expect(SearchTool).toHaveBeenCalledTimes(1);
});
});