Skip to main content
Glama
search.test.ts1.36 kB
import { describe, it, expect } from 'vitest'; import { searchImplementation } from '../search.js'; describe('Search Tool', () => { it('should return search results', async () => { const result = await searchImplementation({ query: 'test query', }); expect(result.query).toBe('test query'); expect(result.results).toBeDefined(); expect(Array.isArray(result.results)).toBe(true); expect(result.count).toBe(result.results.length); }); it('should respect limit parameter', async () => { const result = await searchImplementation({ query: 'test', limit: 2, }); expect(result.results.length).toBeLessThanOrEqual(2); }); it('should use default limit when not specified', async () => { const result = await searchImplementation({ query: 'test', }); expect(result.results.length).toBeLessThanOrEqual(10); }); it('should throw error when query is missing', async () => { await expect(searchImplementation({})).rejects.toThrow('query parameter is required'); }); it('should include proper result structure', async () => { const result = await searchImplementation({ query: 'test', }); expect(result.results[0]).toHaveProperty('id'); expect(result.results[0]).toHaveProperty('title'); expect(result.results[0]).toHaveProperty('score'); }); });

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/krtw00/search-mcp'

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