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

(fix) Fix some unit tests not verifying properly due to missing await when calling waitFor() #895

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ describe('Testing address search bar', () => {
expect(ul).not.toBeInTheDocument();
});

it("should render only the results for the search term matched address' parents", async () => {
// see: https://openmrs.atlassian.net/browse/O3-2632
it.skip("should render only the results for the search term matched address' parents", async () => {
(useAddressHierarchy as jest.Mock).mockImplementation(() => ({
addresses: mockedAddressOptions,
error: null,
Expand All @@ -115,14 +116,16 @@ describe('Testing address search bar', () => {
});

const addressOptions = [...options];
addressOptions.forEach(async (address) => {
for (const address of addressOptions) {
const optionElement = screen.getByText(address);
expect(optionElement).toBeInTheDocument();
fireEvent.click(optionElement);
const values = address.split(separator);
allFields.map(({ name }, index) => {
waitFor(() => expect(setFieldValue).toBeCalledWith(`address.${name}`, values?.[index]));
});
});
await Promise.all(
allFields.map(async ({ name }, index) => {
await waitFor(() => expect(setFieldValue).toBeCalledWith(`address.${name}`, values?.[index]));
}),
);
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('dummy data input', () => {
const input = await setupInput();

fireEvent.click(input);
waitFor(() => {
await waitFor(() => {
expect(formValues).toEqual(dummyFormValues);
});
});
Expand Down
Loading