Skip to content

Commit

Permalink
fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kajambiya committed Mar 13, 2024
1 parent 66f027a commit 3e30d5f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,16 @@ const encounterContext: EncounterContext = {
},
sessionMode: 'enter',
encounterDate: new Date(2020, 11, 29),
setEncounterDate: value => {},
setEncounterDate: (value) => {},

encounterProvider: '2c95f6f5-788e-4e73-9079-5626911231fa',
setEncounterProvider: jest.fn,
};

const renderForm = intialValues => {
const renderForm = (intialValues) => {
render(
<Formik initialValues={intialValues} onSubmit={null}>
{props => (
{(props) => (
<Form>
<OHRIFormContext.Provider
value={{
Expand All @@ -63,7 +66,7 @@ const renderForm = intialValues => {
fields: [question],
isFieldInitializationComplete: true,
isSubmitting: false,
formFieldHandlers: { 'obs': ObsSubmissionHandler }
formFieldHandlers: { obs: ObsSubmissionHandler },
}}>
<OHRIContentSwitcher question={question} onChange={jest.fn()} handler={ObsSubmissionHandler} />
</OHRIFormContext.Provider>
Expand Down
8 changes: 5 additions & 3 deletions src/components/inputs/select/ohri-dropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ const encounterContext: EncounterContext = {
},
sessionMode: 'enter',
encounterDate: new Date(2020, 11, 29),
setEncounterDate: value => {},
setEncounterDate: (value) => {},
encounterProvider: '2c95f6f5-788e-4e73-9079-5626911231fa',
setEncounterProvider: jest.fn,
};

const renderForm = intialValues => {
const renderForm = (intialValues) => {
render(
<Formik initialValues={intialValues} onSubmit={null}>
{props => (
{(props) => (
<Form>
<OHRIFormContext.Provider
value={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const encounterContext: EncounterContext = {
sessionMode: 'enter',
encounterDate: new Date(2023, 8, 29),
setEncounterDate: (value) => {},
encounterProvider: '2c95f6f5-788e-4e73-9079-5626911231fa',
setEncounterProvider: jest.fn,
};

const renderForm = (intialValues) => {
Expand Down
2 changes: 2 additions & 0 deletions src/components/inputs/unspecified/ohri-unspecified.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const encounterContext: EncounterContext = {
sessionMode: 'enter',
encounterDate: new Date(2020, 11, 29),
setEncounterDate: (value) => {},
encounterProvider: '2c95f6f5-788e-4e73-9079-5626911231fa',
setEncounterProvider: jest.fn,
};

const renderForm = (intialValues) => {
Expand Down
8 changes: 5 additions & 3 deletions src/hooks/useInitialValues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe('useInitialValues', () => {
const encounterDate = new Date();

afterEach(() => {
allFormFields.slice(0, 6).forEach(field => {
allFormFields.slice(0, 6).forEach((field) => {
delete field.value;
});
});
Expand All @@ -142,6 +142,8 @@ describe('useInitialValues', () => {
sessionMode: 'enter',
encounterDate: encounterDate,
setEncounterDate: jest.fn,
encounterProvider: '2c95f6f5-788e-4e73-9079-5626911231fa',
setEncounterProvider: jest.fn,
},
formFieldHandlers,
),
Expand Down Expand Up @@ -200,8 +202,8 @@ describe('useInitialValues', () => {
date_of_birth_1: new Date('2023-07-24T00:00:00.000+0000').toLocaleDateString('en-US'),
infant_name_1: ' TDB II',
});
expect(allFormFields.find(field => field.id === 'date_of_birth_1')).not.toBeNull();
expect(allFormFields.find(field => field.id === 'infant_name_1')).not.toBeNull();
expect(allFormFields.find((field) => field.id === 'date_of_birth_1')).not.toBeNull();
expect(allFormFields.find((field) => field.id === 'infant_name_1')).not.toBeNull();
});

it('should verify that the "isBindingComplete" flag is set to true only when the resolution of calculated values are completed', async () => {
Expand Down
2 changes: 2 additions & 0 deletions src/submission-handlers/base-handlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const encounterContext: EncounterContext = {
sessionMode: 'enter',
encounterDate: new Date(2020, 11, 29),
setEncounterDate: (value) => {},
encounterProvider: '2c95f6f5-788e-4e73-9079-5626911231fa',
setEncounterProvider: jest.fn,
};

describe('ObsSubmissionHandler - handleFieldSubmission', () => {
Expand Down
1 change: 0 additions & 1 deletion src/submission-handlers/encounterProviderHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SubmissionHandler } from '..';
import { getEncounterProviders } from '../api/api';
import { OpenmrsEncounter, OHRIFormField } from '../api/types';
import { EncounterContext } from '../ohri-form-context';

Expand Down

0 comments on commit 3e30d5f

Please sign in to comment.