Skip to main content
Glama

Git MCP Server

encoding.test.ts1.57 kB
/** * @fileoverview Tests for the cross-platform encoding helper. * @module tests/utils/internal/encoding.test */ import { afterEach, describe, expect, it, vi } from 'vitest'; import { arrayBufferToBase64 } from '../../../src/utils/internal/encoding.js'; import { runtimeCaps } from '../../../src/utils/internal/runtime.js'; describe('arrayBufferToBase64', () => { const originalHasBuffer = runtimeCaps.hasBuffer; const originalBtoa = globalThis.btoa; afterEach(() => { runtimeCaps.hasBuffer = originalHasBuffer; if (originalBtoa) { globalThis.btoa = originalBtoa; } else { // eslint-disable-next-line @typescript-eslint/no-dynamic-delete delete (globalThis as { btoa?: typeof globalThis.btoa }).btoa; } }); it('encodes using Buffer when available', () => { runtimeCaps.hasBuffer = true; const encoder = new TextEncoder(); const buffer = encoder.encode('hello world'); const result = arrayBufferToBase64(buffer.buffer as ArrayBuffer); expect(result).toBe(Buffer.from('hello world').toString('base64')); }); it('falls back to btoa when Buffer is unavailable', () => { runtimeCaps.hasBuffer = false; const btoaSpy = vi.fn((value: string) => Buffer.from(value, 'binary').toString('base64'), ); globalThis.btoa = btoaSpy as typeof globalThis.btoa; const bytes = new Uint8Array([0, 1, 2, 3]); const result = arrayBufferToBase64(bytes.buffer); expect(btoaSpy).toHaveBeenCalledTimes(1); expect(result).toBe(Buffer.from(bytes).toString('base64')); }); });

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/cyanheads/git-mcp-server'

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