Skip to main content
Glama
AnnotationInput.test.tsx2.33 kB
// SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors // SPDX-License-Identifier: Apache-2.0 import { MockClient } from '@medplum/mock'; import { MedplumProvider } from '@medplum/react-hooks'; import { act, fireEvent, render, screen } from '../test-utils/render'; import type { AnnotationInputProps } from './AnnotationInput'; import { AnnotationInput } from './AnnotationInput'; const medplum = new MockClient(); function setup(args: AnnotationInputProps): void { render( <MedplumProvider medplum={medplum}> <AnnotationInput {...args} /> </MedplumProvider> ); } describe('AnnotationInput', () => { test('Renders undefined value', () => { setup({ path: '', name: 'a', }); expect(screen.queryByDisplayValue('Hello world')).toBeNull(); }); test('Renders default value', () => { setup({ path: '', name: 'a', defaultValue: { text: 'Hello world', }, }); expect(screen.getByDisplayValue('Hello world')).toBeDefined(); }); test('Set value', async () => { const onChange = jest.fn(); setup({ path: '', name: 'a', onChange, }); await act(async () => { fireEvent.change(screen.getByPlaceholderText('Annotation text'), { target: { value: 'TEST' }, }); }); expect(onChange).toHaveBeenCalledWith({ text: 'TEST', authorReference: { display: 'Alice Smith', reference: 'Practitioner/123', }, time: expect.anything(), }); }); test('Set value without change listener', async () => { setup({ path: '', name: 'a', }); await act(async () => { fireEvent.change(screen.getByPlaceholderText('Annotation text'), { target: { value: 'TEST' }, }); }); expect(screen.getByDisplayValue('TEST')).toBeDefined(); }); test('Clear value', async () => { const onChange = jest.fn(); setup({ path: '', name: 'a', defaultValue: { text: 'Hello world', time: '2020-01-01T00:00:00Z', }, onChange, }); await act(async () => { fireEvent.change(screen.getByPlaceholderText('Annotation text'), { target: { value: '' }, }); }); expect(onChange).toHaveBeenCalledWith({}); }); });

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