Skip to main content
Glama
by sinch
verification-service-helper.test.ts1.86 kB
import { getVerificationClient } from '../../../../src/tools/verification/utils/verification-service-helper'; import { ApiFetchClient, SinchClient, VERIFICATION_HOSTNAME } from '@sinch/sdk-core'; import { formatUserAgent } from '../../../../src/utils'; const mockApi = () => ({ setHostname: jest.fn(), }); jest.mock('@sinch/sdk-core', () => { const actual = jest.requireActual('@sinch/sdk-core'); return { ...actual, SinchClient: jest.fn(() => ({ verification: { verifications: mockApi(), verificationStatus: mockApi(), }, })), } }); describe('getVerificationService', () => { const OLD_ENV = process.env; const APPLICATION_KEY = 'test-application-key'; const TOOL_NAME = 'dummy-tool'; beforeEach(() => { jest.resetModules(); process.env = { ...OLD_ENV }; process.env.VERIFICATION_APPLICATION_KEY = APPLICATION_KEY; process.env.VERIFICATION_APPLICATION_SECRET = 'test-application-secret'; }); afterAll(() => { process.env = OLD_ENV; }); test('returns a configured SinchClient from getVerificationService', async () => { const client = getVerificationClient(TOOL_NAME); expect(client).toHaveProperty('verification'); const apis = (client as SinchClient).verification; for(const api of Object.values(apis)) { expect(api.setHostname).toHaveBeenCalledWith(VERIFICATION_HOSTNAME); expect(api.client).toBeInstanceOf(ApiFetchClient); const userAgentPlugin = (api.client as ApiFetchClient).apiClientOptions.requestPlugins?.find((plugin) => plugin.getName() === 'AdditionalHeadersRequest'); expect(userAgentPlugin).toBeDefined(); const expectedUserAgent = formatUserAgent(TOOL_NAME, APPLICATION_KEY); expect((await (userAgentPlugin as any).additionalHeaders.headers)['User-Agent']).toBe(expectedUserAgent); } }); });

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

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