test(extensions): cover web search provider helpers

This commit is contained in:
Vincent Koc
2026-03-22 16:01:56 -07:00
parent e0af23106c
commit bd1c6efca5
4 changed files with 152 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
import { describe, expect, it } from "vitest";
import { __testing } from "./kimi-web-search-provider.js";
describe("kimi web search provider", () => {
it("uses configured model and base url overrides with sane defaults", () => {
expect(__testing.resolveKimiModel()).toBe("moonshot-v1-128k");
expect(__testing.resolveKimiModel({ model: "kimi-k2" })).toBe("kimi-k2");
expect(__testing.resolveKimiBaseUrl()).toBe("https://api.moonshot.ai/v1");
expect(__testing.resolveKimiBaseUrl({ baseUrl: "https://kimi.example/v1" })).toBe(
"https://kimi.example/v1",
);
});
it("extracts unique citations from search results and tool call arguments", () => {
expect(
__testing.extractKimiCitations({
search_results: [
{ url: "https://a.test" },
{ url: "https://b.test" },
],
choices: [
{
message: {
tool_calls: [
{
function: {
arguments: JSON.stringify({
url: "https://a.test",
search_results: [{ url: "https://c.test" }],
}),
},
},
],
},
},
],
}),
).toEqual(["https://a.test", "https://b.test", "https://c.test"]);
});
});