Skip to content

Commit

Permalink
created mocks and removed test
Browse files Browse the repository at this point in the history
  • Loading branch information
ayush-AI committed Jul 13, 2023
1 parent 0d127d8 commit 88e5778
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export const openmrsID = {
name: 'OpenMRS ID',
fieldName: 'openMrsId',
required: true,
uuid: '05a29f94-c0ed-11e2-94be-8c13b969e334',
format: null,
isPrimary: true,
identifierSources: [
{
uuid: '691eed12-c0f1-11e2-94be-8c13b969e334',
name: 'Generator 1 for OpenMRS ID',
autoGenerationOption: {
manualEntryEnabled: false,
automaticGenerationEnabled: true,
},
},
{
uuid: '01af8526-cea4-4175-aa90-340acb411771',
name: 'Generator 2 for OpenMRS ID',
autoGenerationOption: {
manualEntryEnabled: true,
automaticGenerationEnabled: true,
},
},
],
autoGenerationSource: null,
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Resources, ResourcesContext } from '../../../offline.resources';
import { Form, Formik } from 'formik';
import { PatientRegistrationContext } from '../../patient-registration-context';
import { useConfig } from '@openmrs/esm-framework';
import { openmrsID } from '../__mocks__/identifiers.mock';
import { mockedIdentifierTypes } from '../__mocks__/identifier-types.mock';

jest.mock('@openmrs/esm-framework', () => ({
Expand All @@ -24,34 +25,6 @@ describe('Identifiers', () => {
identifierTypes: [...mockedIdentifierTypes],
} as Resources;

const openmrsID = {
name: 'OpenMRS ID',
fieldName: 'openMrsId',
required: true,
uuid: '05a29f94-c0ed-11e2-94be-8c13b969e334',
format: null,
isPrimary: true,
identifierSources: [
{
uuid: '691eed12-c0f1-11e2-94be-8c13b969e334',
name: 'Generator 1 for OpenMRS ID',
autoGenerationOption: {
manualEntryEnabled: false,
automaticGenerationEnabled: true,
},
},
{
uuid: '01af8526-cea4-4175-aa90-340acb411771',
name: 'Generator 2 for OpenMRS ID',
autoGenerationOption: {
manualEntryEnabled: true,
automaticGenerationEnabled: true,
},
},
],
autoGenerationSource: null,
};

(useConfig as jest.Mock).mockImplementation(() => ({
defaultPatientIdentifierTypes: ['OpenMRS ID'],
}));
Expand Down Expand Up @@ -132,33 +105,4 @@ describe('Identifiers', () => {

expect(screen.getByRole('button', { name: 'Close overlay' })).toBeInTheDocument();
});

it('should close identifier selection overlay when "close overlay" button is clicked', () => {
render(
<ResourcesContext.Provider value={mockResourcesContextValue}>
<Formik initialValues={{}} onSubmit={null}>
<Form>
<PatientRegistrationContext.Provider
value={{
setFieldValue: jest.fn(),
initialFormValues: { identifiers: { openmrsID } },
setInitialFormValues: jest.fn(),
values: {
identifiers: { openmrsID },
},
}}>
<Identifiers />
</PatientRegistrationContext.Provider>
</Form>
</Formik>
</ResourcesContext.Provider>,
);

const configureButton = screen.getByRole('button', { name: 'Configure' });
fireEvent.click(configureButton);

const closeBtn = screen.getByRole('button', { name: 'Close overlay' });
fireEvent.click(closeBtn);
expect(closeBtn).not.toBeInTheDocument();
});
});

0 comments on commit 88e5778

Please sign in to comment.