Skip to main content
Glama
IBM

IBM i MCP Server

Official
by IBM
logic.test.ts1.24 kB
import { generateMock } from "@anatine/zod-mock"; import { afterEach, describe, expect, it, vi, type Mock } from "vitest"; import { CatFactFetcherInputSchema, catFactFetcherLogic, CatFactFetcherResponseSchema, } from "../../../../src/mcp-server/tools/catFactFetcher/logic"; import * as networkUtils from "../../../../src/utils/network"; // Mock the fetchWithTimeout utility vi.mock("../../../../src/utils/network", () => ({ fetchWithTimeout: vi.fn(), })); describe("catFactFetcherLogic", () => { afterEach(() => { vi.restoreAllMocks(); }); it("should return a valid cat fact on successful API call", async () => { const mockInput = generateMock(CatFactFetcherInputSchema); const mockApiResponse = { fact: "Cats are cool.", length: 14, }; (networkUtils.fetchWithTimeout as Mock).mockResolvedValue({ ok: true, json: async () => mockApiResponse, }); const result = await catFactFetcherLogic(mockInput); const validation = CatFactFetcherResponseSchema.safeParse(result); expect(validation.success).toBe(true); if (validation.success) { expect(result.fact).toBe(mockApiResponse.fact); expect(result.length).toBe(mockApiResponse.length); } }); });

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/IBM/ibmi-mcp-server'

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