-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.test.ts
More file actions
46 lines (39 loc) · 1.4 KB
/
utils.test.ts
File metadata and controls
46 lines (39 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* Tests for utility functions
*/
import { describe, it, expect } from "vitest";
import { buildClientUserAgent } from "./utils.js";
describe("buildClientUserAgent", () => {
it("should build basic user agent for cli-search", () => {
const ua = buildClientUserAgent("cli-search");
expect(ua).toMatch(/^context-connectors\/\d+\.\d+\.\d+ via:cli-search$/);
});
it("should build basic user agent for cli-index", () => {
const ua = buildClientUserAgent("cli-index");
expect(ua).toMatch(/^context-connectors\/\d+\.\d+\.\d+ via:cli-index$/);
});
it("should build basic user agent for mcp", () => {
const ua = buildClientUserAgent("mcp");
expect(ua).toMatch(/^context-connectors\/\d+\.\d+\.\d+ via:mcp$/);
});
it("should include MCP client info when provided", () => {
const ua = buildClientUserAgent("mcp", { name: "claude-desktop", version: "1.2.0" });
expect(ua).toMatch(/^context-connectors\/\d+\.\d+\.\d+ via:mcp client:claude-desktop\/1\.2\.0$/);
});
it("should handle all interface types", () => {
const interfaces = [
"cli-search",
"sdk-search",
"cli-index",
"sdk-index",
"mcp",
"cli-agent",
"sdk-agent-provider",
] as const;
for (const iface of interfaces) {
const ua = buildClientUserAgent(iface);
expect(ua).toContain(`via:${iface}`);
expect(ua).toContain("context-connectors/");
}
});
});