Skip to main content
Glama
utils.test.ts1.17 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { partition } from './utils'; interface SpecialThing { type: 'special'; } function isSpecialThing(obj: any): obj is SpecialThing { if (!obj) { return false; } return obj.type === 'special'; } describe('partition', () => { test('correctly partitions based on predicate', () => { const notSpecialThings = [undefined, null, Object.create(null), { name: 'not-special' }]; const specialThings = [ { name: 'special1', type: 'special' }, { name: 'special2', type: 'special' }, ]; const allThings: any[] = [...notSpecialThings, ...specialThings]; const results = partition(allThings, isSpecialThing); const specialOutput: SpecialThing[] = results[0]; const anyOutput: any[] = results[1]; expect(specialOutput.length).toStrictEqual(specialThings.length); expect(specialOutput).toStrictEqual(expect.arrayContaining(specialThings)); expect(anyOutput.length).toStrictEqual(notSpecialThings.length); expect(anyOutput).toStrictEqual(expect.arrayContaining(notSpecialThings)); }); });

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