Skip to main content
Glama
keyvalue.test.ts1.39 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { MedplumClient } from './client'; import { mockFetchResponse } from './client-test-utils'; describe('KeyValue', () => { test('Happy path', async () => { const state = { value: undefined, }; const mockFetch = async (url: string, options: any): Promise<any> => { const method = options.method; switch (method) { case 'GET': if (state.value) { return mockFetchResponse(200, state.value, { 'content-type': 'text/plain' }); } else { return mockFetchResponse(404, undefined, { 'content-type': 'text/plain' }); } case 'PUT': state.value = options.body; return mockFetchResponse(204, undefined); case 'DELETE': state.value = undefined; return mockFetchResponse(204, undefined); } throw new Error('Invalid method'); }; const medplum = new MedplumClient({ fetch: mockFetch }); await expect(medplum.keyValue.get('test')).rejects.toThrow('Not found'); await medplum.keyValue.set('test', 'value'); await expect(medplum.keyValue.get('test')).resolves.toBe('value'); await medplum.keyValue.delete('test'); await expect(medplum.keyValue.get('test')).rejects.toThrow('Not found'); }); });

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/medplum/medplum'

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