Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(test) O3-2081: Fix tests for the PatientRegistration component #709

Merged
merged 23 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bb7d73b
fixed all tests except one
ayush-AI May 25, 2023
a4f5529
attempt to fix the failing test
ayush-AI May 25, 2023
9294fea
updated gender to match the value
ayush-AI May 25, 2023
88240c8
fixed failing edit demographic tests
ayush-AI Jun 15, 2023
555a3f1
new describe for patient update
ayush-AI Jun 15, 2023
1097c28
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-patient…
ayush-AI Jun 15, 2023
6589d18
updated the test names
ayush-AI Jun 20, 2023
b31eb69
remove the fireEvent
ayush-AI Jun 20, 2023
2d4786b
fixed test for patient-registration
ayush-AI Jun 29, 2023
a3f1432
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-patient…
ayush-AI Jun 29, 2023
16dd92a
Merge branch 'main' into patient-registration
ayush-AI Jul 1, 2023
beda614
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-patient…
ayush-AI Jul 3, 2023
05fbbc6
Merge branch 'patient-registration' of github.com:ayush-AI/openmrs-es…
ayush-AI Jul 3, 2023
b11a6cd
removed light prop depreciation warning
ayush-AI Jul 4, 2023
906f67c
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-patient…
ayush-AI Jul 4, 2023
2b0a5e5
removed the comment
ayush-AI Jul 4, 2023
bc9d91a
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-patient…
ayush-AI Jul 9, 2023
6e1c2a9
minor fix
ayush-AI Jul 19, 2023
5518fa5
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-patient…
ayush-AI Jul 19, 2023
677dab4
Merge branch 'main' of https://github.com/openmrs/openmrs-esm-patient…
ayush-AI Aug 4, 2023
1531922
minor fix
ayush-AI Aug 4, 2023
2c7726d
Merge branch 'main' into patient-registration
Piumal1999 Aug 10, 2023
3029224
Merge branch 'main' into patient-registration
ayush-AI Aug 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __mocks__/patient.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const mockPatient = {
given: ['John'],
},
],
gender: 'male',
gender: 'Male',
birthDate: '1972-04-04',
deceasedBoolean: false,
address: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,6 @@ import userEvent from '@testing-library/user-event';
import { Formik, Form } from 'formik';
import { Input } from './input.component';

describe.skip('number input', () => {
Piumal1999 marked this conversation as resolved.
Show resolved Hide resolved
const setupInput = async () => {
render(
<Formik initialValues={{ number: 0 }} onSubmit={null}>
<Form>
<Input id="number" type="number" labelText="Number" name="number" />
</Form>
</Formik>,
);
return screen.getByLabelText('Number (optional)') as HTMLInputElement;
};

it('exists', async () => {
const input = await setupInput();
expect(input.type).toEqual('number');
});

it('can input data', async () => {
const user = userEvent.setup();

const input = await setupInput();
const expected = 1;

await user.type(input, expected.toString());
await user.tab();

expect(input.valueAsNumber).toEqual(expected);
});
});

describe('text input', () => {
const setupInput = async () => {
render(
Expand Down Expand Up @@ -100,108 +70,3 @@ describe('text input', () => {
expect(screen.getByLabelText('Text (optional)')).toBeInTheDocument();
});
});

describe.skip('telephone number input', () => {
const setupInput = async () => {
render(
<Formik initialValues={{ telephoneNumber: '' }} onSubmit={null}>
<Form>
<Input id="tel" labelText="Telephone Number" name="telephoneNumber" placeholder="Enter telephone number" />
</Form>
</Formik>,
);
return screen.getByLabelText('telephoneNumber') as HTMLInputElement;
};

it('exists', async () => {
const input = await setupInput();
expect(input.type).toEqual('tel');
});

it('can input data', async () => {
const user = userEvent.setup();

const input = await setupInput();
const expected = '0800001066';

await user.type(input, expected);
await user.tab();

expect(input.value).toEqual(expected);
});
});

describe.skip('date input', () => {
const setupInput = async () => {
render(
<Formik initialValues={{ date: '' }} onSubmit={null}>
<Form>
<Input id="date" labelText="date" name="date" />
</Form>
</Formik>,
);
return screen.getByLabelText('date') as HTMLInputElement;
};

it('exists', async () => {
const input = await setupInput();
expect(input.type).toEqual('date');
});

it('can input data', async () => {
const user = userEvent.setup();

const input = await setupInput();
const expected = '1990-09-10';

await user.type(input, expected);
await user.tab();

expect(input.value).toEqual(expected);
});
});

describe.skip('checkbox input', () => {
const setupInput = async () => {
render(
<Formik initialValues={{ checkbox: false }} onSubmit={null}>
<Form>
<Input id="checkbox" labelText="checkbox" name="checkbox" />
</Form>
</Formik>,
);
return screen.getByLabelText('checkbox') as HTMLInputElement;
};

it('exists', async () => {
const input = await setupInput();
expect(input.type).toEqual('checkbox');
});

it('can input data', async () => {
const user = userEvent.setup();
const input = await setupInput();

const expected = true;

await user.click(input);
await user.tab();

expect(input.checked).toEqual(expected);
});

it('can update data', async () => {
const user = userEvent.setup();
const input = await setupInput();

const expected = false;

await user.click(input);
await user.tab();

await user.click(input);
await user.tab();

expect(input.checked).toEqual(expected);
});
});
Loading
Loading