Skip to main content
Glama
posts.tool.test.ts1.75 kB
import { afterEach, beforeAll, describe, expect, it, jest } from "@jest/globals"; let handleToolCall: typeof import("../posts/tool.js")["handleToolCall"]; let bandApiClient: typeof import("../client.js")["bandApiClient"]; beforeAll(async () => { ({ handleToolCall } = await import("../posts/tool.js")); ({ bandApiClient } = await import("../client.js")); }); afterEach(() => { jest.restoreAllMocks(); }); describe("posts tool handleToolCall", () => { it("derives band key from url when band_key missing", async () => { const getMock = jest .spyOn(bandApiClient, "get") .mockResolvedValue({ paging: { previous_params: null, next_params: null }, items: [], } as never); await handleToolCall( undefined, undefined, undefined, undefined, "https://band.us/band/AAAbBbMeQHBLh3-y8xxogqBg" ); expect(getMock).toHaveBeenCalledWith( "/v2/band/posts", { band_key: "AAAbBbMeQHBLh3-y8xxogqBg", locale: "ja_JP" } ); }); it("respects user provided locale and trims identifiers", async () => { const getMock = jest .spyOn(bandApiClient, "get") .mockResolvedValue({ paging: { previous_params: null, next_params: null }, items: [], } as never); await handleToolCall( " SOME_KEY ", "en_US", undefined, 50, undefined ); expect(getMock).toHaveBeenCalledWith( "/v2/band/posts", { band_key: "SOME_KEY", locale: "en_US", limit: 50 } ); }); it("throws when neither band_key nor url provided", async () => { await expect( handleToolCall(undefined, undefined) ).rejects.toThrow("Either band_key or a valid BAND url must be provided."); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kanghouchao/band-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server