Skip to main content
Glama

Joke MCP Server

by ericqian77
offline.test.js1.21 kB
import { describe, it, expect, vi } from 'vitest'; const failingJokeApi = { getJoke: vi.fn().mockRejectedValue(new Error('JokeAPI offline')) }; const failingOfficial = { getJoke: vi.fn().mockRejectedValue(new Error('Official API offline')) }; const localMock = { getJoke: vi.fn().mockResolvedValue({ text: 'Local fallback joke', category: 'general', source: 'local-fallback' }) }; vi.mock('../../src/providers/jokeapi.js', () => failingJokeApi); vi.mock('../../src/providers/official.js', () => failingOfficial); vi.mock('../../src/providers/local.js', () => localMock); const { resolveJoke } = await import('../../src/jokes-mcp.js'); describe('resolveJoke offline fallback', () => { it('falls back to local provider when network providers fail', async () => { const result = await resolveJoke( { category: 'programming', lang: 'en', blacklist: [] }, { timeoutMs: 10, retries: 0, allowNet: true }, ); expect(result.source).toBe('local-fallback'); expect(result.text).toContain('Local fallback joke'); expect(failingJokeApi.getJoke).toHaveBeenCalled(); expect(failingOfficial.getJoke).toHaveBeenCalled(); expect(localMock.getJoke).toHaveBeenCalled(); }); });

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/ericqian77/joke-mcp'

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