From 908360ac670e3df410ffdc0cde8e8ef0021322e2 Mon Sep 17 00:00:00 2001 From: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> Date: Fri, 14 Feb 2025 15:37:37 -0500 Subject: [PATCH] fix broken unit tests Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> --- .../configuration/Profiles.unit.test.ts | 37 +------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/packages/zowe-explorer/__tests__/__unit__/configuration/Profiles.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/configuration/Profiles.unit.test.ts index 687d4a501..eace85428 100644 --- a/packages/zowe-explorer/__tests__/__unit__/configuration/Profiles.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/configuration/Profiles.unit.test.ts @@ -1229,7 +1229,6 @@ describe("Profiles Unit Tests - function ssoLogin", () => { getTokenTypeName: () => imperative.SessConstants.TOKEN_TYPE_APIML, login: () => "ajshdlfkjshdalfjhas", } as never); - jest.spyOn(Profiles.getInstance() as any, "loginCredentialPrompt").mockReturnValue(["fake", "12345"]); jest.spyOn(Profiles.getInstance() as any, "updateBaseProfileFileLogin").mockImplementation(); await expect(Profiles.getInstance().ssoLogin(testNode, "fake")).resolves.not.toThrow(); }); @@ -1239,7 +1238,6 @@ describe("Profiles Unit Tests - function ssoLogin", () => { login: () => "ajshdlfkjshdalfjhas", getSession: () => globalMocks.testSession, } as never); - jest.spyOn(Profiles.getInstance() as any, "loginCredentialPrompt").mockReturnValue(["fake", "12345"]); await expect(Profiles.getInstance().ssoLogin(testNode, "fake")).resolves.not.toThrow(); }); it("should catch error getting token type and log warning", async () => { @@ -1258,7 +1256,6 @@ describe("Profiles Unit Tests - function ssoLogin", () => { login: jest.fn(), } as never); const loginBaseProfMock = jest.spyOn(ZoweVsCodeExtension, "ssoLogin").mockRejectedValueOnce(new Error("test error.")); - jest.spyOn(Profiles.getInstance() as any, "loginCredentialPrompt").mockReturnValue(["fake", "12345"]); await expect(Profiles.getInstance().ssoLogin(testNode, "fake")).resolves.not.toThrow(); expect(ZoweLogger.error).toHaveBeenCalled(); loginBaseProfMock.mockRestore(); @@ -1271,7 +1268,6 @@ describe("Profiles Unit Tests - function ssoLogin", () => { const profileUpdatedEmitterSpy = jest.spyOn(ZoweVsCodeExtension.onProfileUpdatedEmitter, "fire"); const unlockProfileSpy = jest.spyOn(AuthHandler, "unlockProfile"); const loginBaseProfMock = jest.spyOn(ZoweVsCodeExtension, "ssoLogin").mockResolvedValueOnce(true); - jest.spyOn(Profiles.getInstance() as any, "loginCredentialPrompt").mockReturnValue(["fake", "12345"]); await expect(Profiles.getInstance().ssoLogin(testNode, "fake")).resolves.not.toThrow(); expect(profileUpdatedEmitterSpy).toHaveBeenCalledTimes(1); expect(profileUpdatedEmitterSpy).toHaveBeenCalledWith(globalMocks.testProfile); @@ -1504,7 +1500,7 @@ describe("Profiles Unit Tests - function handleSwitchAuthentication", () => { jest.spyOn(ZoweExplorerApiRegister.getInstance(), "getCommonApi").mockReturnValue({ getTokenTypeName: () => "jwtToken", } as never); - jest.spyOn(Profiles.getInstance() as any, "loginWithRegularProfile").mockResolvedValue(true); + jest.spyOn(ZoweVsCodeExtension as any, "directConnectLogin").mockResolvedValue(true); await Profiles.getInstance().handleSwitchAuthentication(testNode); expect(Gui.showMessage).toHaveBeenCalled(); expect(testNode.profile.profile.tokenType).toBe(modifiedTestNode.profile.profile.tokenType); @@ -1562,7 +1558,6 @@ describe("Profiles Unit Tests - function handleSwitchAuthentication", () => { jest.spyOn(ZoweExplorerApiRegister.getInstance(), "getCommonApi").mockReturnValue({ getTokenTypeName: () => "jwtToken", } as never); - jest.spyOn(Profiles.getInstance() as any, "loginWithRegularProfile").mockResolvedValue(false); await Profiles.getInstance().handleSwitchAuthentication(testNode); expect(Gui.errorMessage).toHaveBeenCalled(); expect(testNode.profile.profile.tokenType).toBe(modifiedTestNode.profile.profile.tokenType); @@ -1977,36 +1972,6 @@ describe("Profiles Unit Tests - function validationArraySetup", () => { }); }); -describe("Profiles Unit Tests - function loginCredentialPrompt", () => { - afterEach(() => { - jest.resetAllMocks(); - jest.clearAllMocks(); - }); - - it("should show a gui message if there is not a newUser", async () => { - const privateProfile = Profiles.getInstance() as any; - Object.defineProperty(privateProfile, "userInfo", { - value: () => null, - }); - const showMessageSpy = jest.spyOn(Gui, "showMessage").mockImplementation(); - await expect(privateProfile.loginCredentialPrompt()).resolves.toEqual(undefined); - expect(showMessageSpy).toHaveBeenCalledTimes(1); - }); - - it("should show a gui message if there is not a newUser", async () => { - const privateProfile = Profiles.getInstance() as any; - Object.defineProperty(Profiles, "getInstance", { - value: () => ({ - userInfo: () => "test", - passwordInfo: () => null, - }), - }); - const showMessageSpy = jest.spyOn(Gui, "showMessage").mockImplementation(); - await expect(privateProfile.loginCredentialPrompt()).resolves.toEqual(undefined); - expect(showMessageSpy).toHaveBeenCalledTimes(1); - }); -}); - describe("Profiles Unit Tests - function getSecurePropsForProfile", () => { afterEach(() => { jest.clearAllMocks();