Skip to main content
Glama
FhirPathDisplay.test.tsx1.93 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { PropertyType } from '@medplum/core'; import type { Patient } from '@medplum/fhirtypes'; import { MockClient } from '@medplum/mock'; import { render, screen } from '../test-utils/render'; import { FhirPathDisplay } from './FhirPathDisplay'; describe('FhirPathDisplay', () => { beforeAll(async () => { await new MockClient().requestSchema('Patient'); }); test('Renders single value', () => { const patient: Patient = { resourceType: 'Patient', name: [ { given: ['Alice'], family: 'Smith', }, ], }; render(<FhirPathDisplay resource={patient} path="Patient.name.given" propertyType={PropertyType.string} />); expect(screen.getByText('Alice')).toBeDefined(); }); test('Error on multiple values', () => { const patient: Patient = { resourceType: 'Patient', name: [ { given: ['Alice', 'Ann'], family: 'Smith', }, ], }; expect(() => render(<FhirPathDisplay resource={patient} path="Patient.name.given" propertyType={PropertyType.string} />) ).toThrow('must resolve to a single element'); }); test('Handles null name', () => { render( <FhirPathDisplay resource={{ resourceType: 'Patient', }} path="Patient.name.given" propertyType={PropertyType.string} /> ); }); test('Handles malformed date', () => { console.warn = jest.fn(); render( <FhirPathDisplay resource={{ resourceType: 'Patient', birthDate: 'not a date', }} path="between(birthDate, now(), 'years')" propertyType={PropertyType.string} /> ); expect(console.warn).toHaveBeenCalledWith('FhirPathDisplay:', expect.any(Error)); }); });

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