Skip to content

Commit

Permalink
Added mock setSessionLocation to pass the tests (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
vasharma05 authored Apr 4, 2022
1 parent 1020f67 commit 19b47a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/apps/esm-login-app/__mocks__/locations.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,5 @@ export const mockSoleLoginLocation = {
],
},
};

export const mockSetSessionLocation = Promise.resolve();
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { waitFor } from "@testing-library/react";
import renderWithRouter from "../test-helpers/render-with-router";
import { navigate, openmrsFetch, useConfig } from "@openmrs/esm-framework";
import { mockSoleLoginLocation } from "../../__mocks__/locations.mock";
import {
mockSetSessionLocation,
mockSoleLoginLocation,
} from "../../__mocks__/locations.mock";
import { mockConfig } from "../../__mocks__/config.mock";
import ChooseLocation from "./choose-location.component";

Expand Down Expand Up @@ -29,6 +32,7 @@ describe("ChooseLocation: ", () => {

it("auto-selects the location and navigates away from the page when only one login location is available", async () => {
mockedOpenmrsFetch.mockReturnValueOnce(mockSoleLoginLocation);
mockedOpenmrsFetch.mockReturnValueOnce(mockSetSessionLocation);

renderWithRouter(ChooseLocation, { isLoginEnabled: true });

Expand Down

0 comments on commit 19b47a5

Please sign in to comment.