openclaw/extensions/tavily/index.test.ts
Lakshya Agarwal b36e456b09
feat: add Tavily as a bundled web search plugin with search and extract tools (#49200)
Merged via squash.

Prepared head SHA: ece9226e886004f1e0536dd5de3ddc2946fc118c
Co-authored-by: lakshyaag-tavily <266572148+lakshyaag-tavily@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
2026-03-20 01:06:26 -04:00

42 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import plugin from "./index.js";
describe("tavily plugin", () => {
it("exports a valid plugin entry with correct id and name", () => {
expect(plugin.id).toBe("tavily");
expect(plugin.name).toBe("Tavily Plugin");
expect(typeof plugin.register).toBe("function");
});
it("registers web search provider and two tools", () => {
const registrations: {
webSearchProviders: unknown[];
tools: unknown[];
} = { webSearchProviders: [], tools: [] };
const mockApi = {
registerWebSearchProvider(provider: unknown) {
registrations.webSearchProviders.push(provider);
},
registerTool(tool: unknown) {
registrations.tools.push(tool);
},
config: {},
};
plugin.register(mockApi as never);
expect(registrations.webSearchProviders).toHaveLength(1);
expect(registrations.tools).toHaveLength(2);
const provider = registrations.webSearchProviders[0] as Record<string, unknown>;
expect(provider.id).toBe("tavily");
expect(provider.autoDetectOrder).toBe(70);
expect(provider.envVars).toEqual(["TAVILY_API_KEY"]);
const toolNames = registrations.tools.map((t) => (t as Record<string, unknown>).name);
expect(toolNames).toContain("tavily_search");
expect(toolNames).toContain("tavily_extract");
});
});