Menu
popagent
publicLatest change 6edc7e928c57dab23c0973ed3f7ee70b3ebb72d5 - Initial popagent baseline by AkurAI Build
import { afterAll, describe, expect, test } from "bun:test";
import { searchWeb } from "./web-search";
const server = Bun.serve({
port: 0,
routes: {
"/search": (request) => {
const url = new URL(request.url);
expect(url.searchParams.get("q")).toBe("mastra agents");
expect(url.searchParams.get("format")).toBe("json");
return Response.json({
results: [
{ title: "Mastra", url: "https://mastra.ai/docs", content: "Agent framework", engine: "brave" },
{ title: "Invalid result" },
{ title: "Mastra GitHub", url: "https://github.com/mastra-ai/mastra" },
],
});
},
},
});
afterAll(() => server.stop(true));
describe("web search", () => {
test("queries SearXNG JSON and normalizes results", async () => {
const result = await searchWeb("mastra agents", 2, `http://127.0.0.1:${server.port}`);
expect(result).toEqual({
query: "mastra agents",
results: [
{ title: "Mastra", url: "https://mastra.ai/docs", content: "Agent framework", engine: "brave" },
{ title: "Mastra GitHub", url: "https://github.com/mastra-ai/mastra", content: "", engine: undefined },
],
});
});
});