Skip to content

Commit

Permalink
Enable MultiSelect component test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel090 committed Sep 16, 2024
1 parent 6f36300 commit f332eaf
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/components/inputs/multi-select/multi-select.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { act, render, screen } from '@testing-library/react';
import { userEvent } from '@testing-library/user-event';
import userEvent from '@testing-library/user-event'; // Correct import for userEvent
import { type FetchResponse, openmrsFetch, usePatient, useSession } from '@openmrs/esm-framework';
import { type FormSchema } from '../../../types';
import { mockPatient } from '__mocks__/patient.mock';
Expand Down Expand Up @@ -31,7 +31,7 @@ jest.mock('../../../api', () => {
});

const renderForm = async () => {
await act(() =>
await act(async () => {
render(
<FormEngine
formJson={multiSelectFormSchema as unknown as FormSchema}
Expand All @@ -40,11 +40,11 @@ const renderForm = async () => {
formSessionIntent={undefined}
visit={visit}
/>,
),
);
);
});
};

describe.skip('MultiSelect Component', () => {
describe('MultiSelect Component', () => {
beforeEach(() => {
mockOpenmrsFetch.mockResolvedValue({
data: { results: [{ ...multiSelectFormSchema }] },
Expand All @@ -69,22 +69,20 @@ describe.skip('MultiSelect Component', () => {
it('should disable checkbox option if the field value depends on evaluates the expression to true', async () => {
const user = userEvent.setup();
await renderForm();

await user.click(screen.getByRole('combobox', { name: /Patient covered by NHIF/i }));
await user.click(screen.getByRole('option', { name: /no/i }));

await user.click(screen.getByText('Was this visit scheduled?'));
expect(screen.getByRole('option', { name: /Unscheduled visit early/i })).toHaveAttribute('disabled');
const unscheduledVisitOption = screen.getByRole('option', { name: /Unscheduled visit early/i });
expect(unscheduledVisitOption).toHaveAttribute('disabled');
});

it('should enable checkbox option if the field value depends on evaluates the expression to false', async () => {
const user = userEvent.setup();
await renderForm();

await user.click(screen.getByRole('combobox', { name: /patient covered by nhif/i }));
await user.click(screen.getByRole('option', { name: /yes/i }));

await user.click(screen.getByText('Was this visit scheduled?'));
expect(screen.getByRole('option', { name: /Unscheduled visit early/i })).not.toHaveAttribute('disabled');
const unscheduledVisitOption = screen.getByRole('option', { name: /Unscheduled visit early/i });
expect(unscheduledVisitOption).not.toBeDisabled();
});
});

0 comments on commit f332eaf

Please sign in to comment.