From 19b47a55ed8816ae45d61b2b71d3123f7e34fde4 Mon Sep 17 00:00:00 2001 From: Vineet Sharma Date: Mon, 4 Apr 2022 22:47:47 +0530 Subject: [PATCH] Added mock setSessionLocation to pass the tests (#377) --- packages/apps/esm-login-app/__mocks__/locations.mock.ts | 2 ++ .../src/choose-location/choose-location.test.tsx | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/apps/esm-login-app/__mocks__/locations.mock.ts b/packages/apps/esm-login-app/__mocks__/locations.mock.ts index 88dcd124c..d52150a7d 100644 --- a/packages/apps/esm-login-app/__mocks__/locations.mock.ts +++ b/packages/apps/esm-login-app/__mocks__/locations.mock.ts @@ -395,3 +395,5 @@ export const mockSoleLoginLocation = { ], }, }; + +export const mockSetSessionLocation = Promise.resolve(); diff --git a/packages/apps/esm-login-app/src/choose-location/choose-location.test.tsx b/packages/apps/esm-login-app/src/choose-location/choose-location.test.tsx index e7f09b525..99e1d8698 100644 --- a/packages/apps/esm-login-app/src/choose-location/choose-location.test.tsx +++ b/packages/apps/esm-login-app/src/choose-location/choose-location.test.tsx @@ -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"; @@ -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 });