Skip to main content
Glama
pagination-edge-cases.test.ts2.42 kB
import { describe, it, expect } from 'vitest'; import { paginationToParams, PaginationOptions } from '../../api/types.js'; describe('Pagination Edge Cases', () => { describe('conflicting parameters', () => { it('should prefer page over offset when both provided', () => { const options: PaginationOptions = { page: 2, offset: 10, perPage: 20, limit: 50, }; const result = paginationToParams(options); expect(result).toEqual({ page: 2, perPage: 20, }); expect(result.offset).toBeUndefined(); expect(result.limit).toBeUndefined(); }); it('should prefer perPage over limit when both provided', () => { const options: PaginationOptions = { page: 1, perPage: 25, limit: 100, }; const result = paginationToParams(options); expect(result).toEqual({ page: 1, perPage: 25, }); expect(result.limit).toBeUndefined(); }); }); describe('boundary values', () => { it('should handle page 1 (first page)', () => { expect(paginationToParams({ page: 1, perPage: 10 })).toEqual({ page: 1, perPage: 10, }); }); it('should handle very large page numbers', () => { expect(paginationToParams({ page: 999999, perPage: 10 })).toEqual({ page: 999999, perPage: 10, }); }); it('should handle very large perPage values', () => { expect(paginationToParams({ page: 1, perPage: 1000000 })).toEqual({ page: 1, perPage: 1000000, }); }); }); describe('zero and negative values', () => { it('should allow zero offset', () => { expect(paginationToParams({ offset: 0, limit: 10 })).toEqual({ offset: 0, limit: 10, }); }); it('should allow negative values (API will handle validation)', () => { expect(paginationToParams({ page: -1, perPage: -10 })).toEqual({ page: -1, perPage: -10, }); }); }); });

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/razavioo/liara-mcp'

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