mirror of
https://github.com/kennethnym/aris.git
synced 2026-06-16 12:31:17 +01:00
feat: add google maps mcp source (#125)
This commit is contained in:
55
apps/freya-backend/src/google-maps/provider.test.ts
Normal file
55
apps/freya-backend/src/google-maps/provider.test.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import type { GoogleMapsSourceOptions } from "@freya/source-google-maps"
|
||||
|
||||
import { describe, expect, test } from "bun:test"
|
||||
|
||||
import { GoogleMapsSourceProvider } from "./provider.ts"
|
||||
|
||||
type McpClient = NonNullable<GoogleMapsSourceOptions["client"]>
|
||||
|
||||
class MockMcpClient implements McpClient {
|
||||
async listTools(): ReturnType<McpClient["listTools"]> {
|
||||
return { tools: [] }
|
||||
}
|
||||
|
||||
async readResource(
|
||||
_params: Parameters<McpClient["readResource"]>[0],
|
||||
): ReturnType<McpClient["readResource"]> {
|
||||
throw new Error("unexpected resource read")
|
||||
}
|
||||
|
||||
async callTool(_params: Parameters<McpClient["callTool"]>[0]): ReturnType<McpClient["callTool"]> {
|
||||
return { structuredContent: {} }
|
||||
}
|
||||
}
|
||||
|
||||
describe("GoogleMapsSourceProvider", () => {
|
||||
test("sourceId is freya.google-maps", () => {
|
||||
const provider = new GoogleMapsSourceProvider({ apiKey: "key" })
|
||||
expect(provider.sourceId).toBe("freya.google-maps")
|
||||
})
|
||||
|
||||
test("throws when service API key is empty", () => {
|
||||
expect(() => new GoogleMapsSourceProvider({ apiKey: "" })).toThrow(
|
||||
"Google Maps MCP API key must be configured",
|
||||
)
|
||||
})
|
||||
|
||||
test("returns source with service API key", async () => {
|
||||
const provider = new GoogleMapsSourceProvider({ apiKey: "key" })
|
||||
|
||||
const source = await provider.feedSourceForUser("user-1", {}, null)
|
||||
|
||||
expect(source.id).toBe("freya.google-maps")
|
||||
})
|
||||
|
||||
test("allows injected test client with service API key", async () => {
|
||||
const provider = new GoogleMapsSourceProvider({
|
||||
apiKey: "key",
|
||||
client: new MockMcpClient(),
|
||||
})
|
||||
|
||||
const source = await provider.feedSourceForUser("user-1", {}, null)
|
||||
|
||||
expect(source.id).toBe("freya.google-maps")
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user