From 0ebfb9787399f871f259a0e412ccec3c0787180a Mon Sep 17 00:00:00 2001 From: jellypuno Date: Tue, 3 Mar 2020 14:31:53 +0100 Subject: [PATCH 1/7] redo reprompt Cred Signed-off-by: jellypuno --- __tests__/__unit__/DatasetTree.unit.test.ts | 48 +++++++++++++++----- __tests__/__unit__/Profiles.unit.test.ts | 26 ++++++++++- i18n/sample/src/utils.i18n.json | 5 +-- src/Profiles.ts | 50 ++++++++++++++++++--- src/extension.ts | 2 +- src/utils.ts | 15 +++++-- 6 files changed, 120 insertions(+), 26 deletions(-) diff --git a/__tests__/__unit__/DatasetTree.unit.test.ts b/__tests__/__unit__/DatasetTree.unit.test.ts index 0bb7774dfa..7af4f1739c 100644 --- a/__tests__/__unit__/DatasetTree.unit.test.ts +++ b/__tests__/__unit__/DatasetTree.unit.test.ts @@ -112,15 +112,6 @@ describe("DatasetTree Unit Tests", () => { failNotFound: false }; mockLoadNamedProfile.mockReturnValue(profileOne); - Object.defineProperty(Profiles, "getInstance", { - value: jest.fn(() => { - return { - allProfiles: [{name: "firstName"}, {name: "secondName"}], - defaultProfile: {name: "firstName"}, - loadNamedProfile: mockLoadNamedProfile - }; - }) - }); const testTree = new DatasetTree(); testTree.mSessionNodes.push(new ZoweDatasetNode("testSess", vscode.TreeItemCollapsibleState.Collapsed, null, session, undefined, undefined, profileOne)); @@ -135,6 +126,17 @@ describe("DatasetTree Unit Tests", () => { withProgress.mockImplementation((progLocation, callback) => { return callback(); }); + Object.defineProperty(Profiles, "getInstance", { + value: jest.fn(() => { + return { + allProfiles: [{name: "firstName"}, {name: "secondName"}], + defaultProfile: {name: "firstName"}, + loadNamedProfile: mockLoadNamedProfile, + promptCredentials: jest.fn(), + updateProfile: jest.fn() + }; + }) + }); }); afterAll(() => { @@ -459,7 +461,7 @@ describe("DatasetTree Unit Tests", () => { defaultProfile: {name: "firstName"}, loadNamedProfile: mockLoadNamedProfile, promptCredentials: jest.fn(()=> { - return [{values: "fake"}, {values: "fake"}, {values: "fake"}]; + return ["fake", "fake", "fake"]; }), }; }) @@ -489,7 +491,7 @@ describe("DatasetTree Unit Tests", () => { defaultProfile: {name: "firstName"}, loadNamedProfile: mockLoadNamedProfile, promptCredentials: jest.fn(()=> { - return [{values: "fake"}, {values: "fake"}, {values: "fake"}]; + return ["fake", "fake", "fake"]; }), }; }) @@ -749,7 +751,7 @@ describe("DatasetTree Unit Tests", () => { allProfiles: [{name: "firstName", profile: {user:undefined, password: undefined}}, {name: "secondName"}], defaultProfile: {name: "firstName"}, promptCredentials: jest.fn(()=> { - return [{values: "fake"}, {values: "fake"}, {values: "fake"}]; + return ["fake", "fake", "fake"]; }), }; }) @@ -938,6 +940,28 @@ describe("DatasetTree Unit Tests", () => { showQuickPick.mockReset(); showInputBox.mockReset(); showErrorMessage.mockReset(); + showErrorMessage.mockResolvedValueOnce("Check Credentials"); + + const label = "invalidCred"; + // tslint:disable-next-line: object-literal-key-quotes + const error = {"mDetails": {"errorCode": 401}}; + await utils.errorHandling(error, label); + + expect(showErrorMessage.mock.calls.length).toEqual(1); + expect(showErrorMessage.mock.calls[0][0]).toEqual("Invalid Credentials. Please ensure the username and password for " + + `\n${label}\n` + + " are valid or this may lead to a lock-out."); + }); + + it("tests utils error handling: Theia", async () => { + showQuickPick.mockReset(); + showInputBox.mockReset(); + showErrorMessage.mockReset(); + + showErrorMessage.mockResolvedValueOnce("Check Credentials"); + + const theia = true; + Object.defineProperty(extension, "ISTHEIA", { get: () => theia }); const label = "invalidCred"; // tslint:disable-next-line: object-literal-key-quotes diff --git a/__tests__/__unit__/Profiles.unit.test.ts b/__tests__/__unit__/Profiles.unit.test.ts index b74bf28aeb..26fb9a471e 100644 --- a/__tests__/__unit__/Profiles.unit.test.ts +++ b/__tests__/__unit__/Profiles.unit.test.ts @@ -15,7 +15,7 @@ import * as path from "path"; import * as os from "os"; import * as vscode from "vscode"; import * as child_process from "child_process"; -import { Logger, ISession } from "@zowe/imperative"; +import { Logger, ISession, CliProfileManager } from "@zowe/imperative"; import { Profiles } from "../../src/Profiles"; import { ZosmfSession } from "@zowe/cli"; @@ -132,6 +132,9 @@ describe("Profile class unit tests", () => { validateAndParseUrl: jest.fn(()=>{ return {}; }), + updateProfile: jest.fn(()=>{ + return {}; + }), }; }) }); @@ -281,6 +284,27 @@ describe("Profile class unit tests", () => { (profiles.loadNamedProfile as any).mockReset(); }); + it("should rePrompt credentials", async () => { + const promptProfile = {name: "profile1", profile: {user: "oldfake", password: "oldfake"}}; + profiles.loadNamedProfile = jest.fn(() => { + return promptProfile as any; + }); + + Object.defineProperty(ZosmfSession, "createBasicZosmfSession", { + value: jest.fn(() => { + return { ISession: {user: "fake", password: "fake", base64EncodedAuth: "fake"} }; + }) + }); + + showInputBox.mockResolvedValueOnce("fake"); + showInputBox.mockResolvedValueOnce("fake"); + const res = await profiles.promptCredentials(promptProfile.name, true); + expect(res[0]).toBe("fake"); + expect(res[1]).toBe("fake"); + expect(res[2]).toBe("fake"); + (profiles.loadNamedProfile as any).mockReset(); + }); + it("should prompt credentials: username invalid", async () => { const promptProfile = {name: "profile1", profile: {user: undefined, password: undefined}}; profiles.loadNamedProfile = jest.fn(() => { diff --git a/i18n/sample/src/utils.i18n.json b/i18n/sample/src/utils.i18n.json index 8011020fb4..bc8b21eb8e 100644 --- a/i18n/sample/src/utils.i18n.json +++ b/i18n/sample/src/utils.i18n.json @@ -1,7 +1,6 @@ { "zosJobsProvider.option.prompt.createOwner": "Owner/Prefix Job Search", "zosJobsProvider.option.prompt.createId": "Job Id search", - "errorHandling.invalid.credentials": "Invalid Credentials. ", - "errorHandling.invalid.credentials2": "Please ensure the username and password for ", - "errorHandling.invalid.credentials3": " are valid or this may lead to a lock-out." + "errorHandling.invalid.credentials": "Invalid Credentials. Please ensure the username and password for ", + "errorHandling.invalid.credentials2": " are valid or this may lead to a lock-out." } \ No newline at end of file diff --git a/src/Profiles.ts b/src/Profiles.ts index 7caf9ef200..5d942d470c 100644 --- a/src/Profiles.ts +++ b/src/Profiles.ts @@ -9,7 +9,7 @@ * * */ -import { IProfileLoaded, Logger, CliProfileManager, IProfile, ISession, ImperativeConfig } from "@zowe/imperative"; +import { IProfileLoaded, Logger, CliProfileManager, IProfile, ISession, IUpdateProfile } from "@zowe/imperative"; import * as nls from "vscode-nls"; import * as path from "path"; import { URL } from "url"; @@ -49,7 +49,7 @@ export class Profiles { private static loader: Profiles; public allProfiles: IProfileLoaded[] = []; - + public loadedProfile: IProfileLoaded; private profilesByType = new Map(); private defaultProfileByType = new Map(); private profileManagerByType= new Map(); @@ -242,7 +242,7 @@ export class Profiles { return profileName; } - public async promptCredentials(sessName) { + public async promptCredentials(sessName, rePrompt?: boolean) { let userName: string; let passWord: string; let options: vscode.InputBoxOptions; @@ -250,7 +250,12 @@ export class Profiles { const loadProfile = this.loadNamedProfile(sessName.trim()); const loadSession = loadProfile.profile as ISession; - if (!loadSession.user) { + if (rePrompt) { + userName = loadSession.user; + passWord = loadSession.password; + } + + if (!loadSession.user || rePrompt) { options = { placeHolder: localize("promptcredentials.option.prompt.username.placeholder", "User Name"), @@ -268,7 +273,7 @@ export class Profiles { } } - if (!loadSession.password) { + if (!loadSession.password || rePrompt) { passWord = loadSession.password; options = { @@ -288,9 +293,44 @@ export class Profiles { } } const updSession = await zowe.ZosmfSession.createBasicZosmfSession(loadSession as IProfile); + if (rePrompt) { + await this.updateProfile(loadProfile); + } return [updSession.ISession.user, updSession.ISession.password, updSession.ISession.base64EncodedAuth]; } + private async updateProfile(ProfileInfo) { + + for (const type of ZoweExplorerApiRegister.getInstance().registeredApiTypes()) { + const profileManager = await this.getCliProfileManager(type); + this.loadedProfile = (await profileManager.load({ name: ProfileInfo.name })); + } + + + const OrigProfileInfo = this.loadedProfile.profile as ISession; + const NewProfileInfo = ProfileInfo.profile; + + if (OrigProfileInfo.user) { + OrigProfileInfo.user = NewProfileInfo.user; + } + + if (OrigProfileInfo.password) { + OrigProfileInfo.password = NewProfileInfo.password; + } + + const updateParms: IUpdateProfile = { + name: this.loadedProfile.name, + merge: true, + profile: OrigProfileInfo as IProfile + }; + + try { + (await this.getCliProfileManager(this.loadedProfile.type)).update(updateParms); + } catch (error) { + vscode.window.showErrorMessage(error.message); + } + } + private async saveProfile(ProfileInfo, ProfileName, ProfileType) { let zosmfProfile: IProfile; try { diff --git a/src/extension.ts b/src/extension.ts index 3b6b854b3d..1a14f053ef 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -716,7 +716,7 @@ export async function addZoweSession(zoweFileProvider: IZoweTree { + Profiles.getInstance().promptCredentials(label.trim(), true); + }); + } break; } default: { From e23cc05aa758bdb17790115fd63535288308d9c1 Mon Sep 17 00:00:00 2001 From: jellypuno Date: Wed, 4 Mar 2020 10:40:34 +0100 Subject: [PATCH 2/7] Add changes for issue 417 Signed-off-by: jellypuno --- src/extension.ts | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 1a14f053ef..f256a5bcaa 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -633,7 +633,7 @@ export async function addZoweSession(zoweFileProvider: IZoweTree { @@ -681,20 +681,22 @@ export async function addZoweSession(zoweFileProvider: IZoweTree 0) { + quickpick.items = [createPick, ...items]; + quickpick.placeholder = placeholder; + quickpick.ignoreFocusOut = true; + quickpick.show(); + const choice = await utils.resolveQuickPickHelper(quickpick); + quickpick.hide(); + if (!choice) { + vscode.window.showInformationMessage(localize("enterPattern.pattern", "No selection made.")); + return; + } + if (choice instanceof utils.FilterDescriptor) { + chosenProfile = ""; + } else { + chosenProfile = choice.label; + } } } From ba9f2a3a355c781959c30f439b3598b75607de4d Mon Sep 17 00:00:00 2001 From: jellypuno Date: Wed, 4 Mar 2020 15:04:41 +0100 Subject: [PATCH 3/7] add condition in selection and cleanup some unused imports Signed-off-by: jellypuno --- src/dataset/dsNodeActions.ts | 4 ---- src/utils.ts | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/dataset/dsNodeActions.ts b/src/dataset/dsNodeActions.ts index f839651a2c..dd2e1ef90f 100644 --- a/src/dataset/dsNodeActions.ts +++ b/src/dataset/dsNodeActions.ts @@ -15,12 +15,8 @@ import * as nls from "vscode-nls"; const localize = nls.config({messageFormat: nls.MessageFormat.file})(); import * as extension from "../extension"; import { Profiles } from "../Profiles"; -import { ISession, Logger } from "@zowe/imperative"; -import { DatasetTree } from "../DatasetTree"; import { IZoweTree } from "../api/IZoweTree"; import { IZoweDatasetTreeNode } from "../api/IZoweTreeNode"; -// tslint:disable-next-line: prefer-const -let log: Logger; /** * Refreshes treeView * diff --git a/src/utils.ts b/src/utils.ts index 6367b7ac72..19f6c48de0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -9,7 +9,7 @@ * * */ -import { TreeItem, QuickPickItem, QuickPick, window } from "vscode"; +import { TreeItem, QuickPickItem, QuickPick, window, TreeItemCollapsibleState } from "vscode"; import * as extension from "../src/extension"; import { ISession } from "@zowe/imperative"; import { Profiles } from "./Profiles"; @@ -120,7 +120,9 @@ export function errorHandling(errorDetails: any, label?: string, moreInfo?: stri Profiles.getInstance().promptCredentials(label.trim()); } else { window.showErrorMessage(errMsg, "Check Credentials").then((selection) => { - Profiles.getInstance().promptCredentials(label.trim(), true); + if (selection) { + Profiles.getInstance().promptCredentials(label.trim(), true); + } }); } break; @@ -154,4 +156,5 @@ export function refreshTree(sessNode: IZoweTreeNode) { } } } + sessNode.collapsibleState = TreeItemCollapsibleState.Collapsed; } From 0691dcc1c65ef91562c216abc2d4b824bd0950fe Mon Sep 17 00:00:00 2001 From: jellypuno Date: Thu, 5 Mar 2020 14:20:14 +0100 Subject: [PATCH 4/7] Fix USS sessName Signed-off-by: jellypuno --- src/Profiles.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Profiles.ts b/src/Profiles.ts index 5d942d470c..518b8ca5c3 100644 --- a/src/Profiles.ts +++ b/src/Profiles.ts @@ -247,6 +247,10 @@ export class Profiles { let passWord: string; let options: vscode.InputBoxOptions; + if (sessName.includes("[")) { + sessName = sessName.substring(0, sessName.indexOf(" [")); + } + const loadProfile = this.loadNamedProfile(sessName.trim()); const loadSession = loadProfile.profile as ISession; From 36ff7fb6f6be6f9f2a8e65fec50d9e5f8dfdd691 Mon Sep 17 00:00:00 2001 From: jellypuno Date: Thu, 5 Mar 2020 17:00:36 +0100 Subject: [PATCH 5/7] handle profile name with [ and add test Signed-off-by: jellypuno --- __tests__/__unit__/DatasetTree.unit.test.ts | 17 +++++++++++++++++ src/Profiles.ts | 4 ---- src/utils.ts | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/__tests__/__unit__/DatasetTree.unit.test.ts b/__tests__/__unit__/DatasetTree.unit.test.ts index 7af4f1739c..c4a019c25d 100644 --- a/__tests__/__unit__/DatasetTree.unit.test.ts +++ b/__tests__/__unit__/DatasetTree.unit.test.ts @@ -953,6 +953,23 @@ describe("DatasetTree Unit Tests", () => { " are valid or this may lead to a lock-out."); }); + it("tests utils error handling USS", async () => { + showQuickPick.mockReset(); + showInputBox.mockReset(); + showErrorMessage.mockReset(); + showErrorMessage.mockResolvedValueOnce("Check Credentials"); + + const label = "invalidCred [/tmp]"; + // tslint:disable-next-line: object-literal-key-quotes + const error = {"mDetails": {"errorCode": 401}}; + await utils.errorHandling(error, label); + + expect(showErrorMessage.mock.calls.length).toEqual(1); + expect(showErrorMessage.mock.calls[0][0]).toEqual("Invalid Credentials. Please ensure the username and password for " + + `\n${label}\n` + + " are valid or this may lead to a lock-out."); + }); + it("tests utils error handling: Theia", async () => { showQuickPick.mockReset(); showInputBox.mockReset(); diff --git a/src/Profiles.ts b/src/Profiles.ts index 518b8ca5c3..5d942d470c 100644 --- a/src/Profiles.ts +++ b/src/Profiles.ts @@ -247,10 +247,6 @@ export class Profiles { let passWord: string; let options: vscode.InputBoxOptions; - if (sessName.includes("[")) { - sessName = sessName.substring(0, sessName.indexOf(" [")); - } - const loadProfile = this.loadNamedProfile(sessName.trim()); const loadSession = loadProfile.profile as ISession; diff --git a/src/utils.ts b/src/utils.ts index 19f6c48de0..f6fdff4069 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -115,6 +115,10 @@ export function errorHandling(errorDetails: any, label?: string, moreInfo?: stri switch(httpErrCode) { // tslint:disable-next-line: no-magic-numbers case 401 : { + if (label.includes("[")) { + label = label.substring(0, label.indexOf(" [")); + } + if (extension.ISTHEIA) { window.showErrorMessage(errMsg); Profiles.getInstance().promptCredentials(label.trim()); From 714c881e0955d95a478b306ccf6861d726e5911b Mon Sep 17 00:00:00 2001 From: jellypuno Date: Fri, 6 Mar 2020 16:02:51 +0100 Subject: [PATCH 6/7] add test in rename Signed-off-by: jellypuno --- __tests__/__unit__/DatasetTree.unit.test.ts | 30 +++++++++++++++++++++ src/extension.ts | 30 ++++++++++----------- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/__tests__/__unit__/DatasetTree.unit.test.ts b/__tests__/__unit__/DatasetTree.unit.test.ts index c4a019c25d..595b39376e 100644 --- a/__tests__/__unit__/DatasetTree.unit.test.ts +++ b/__tests__/__unit__/DatasetTree.unit.test.ts @@ -719,6 +719,36 @@ describe("DatasetTree Unit Tests", () => { expect(testTree.mFavorites[0].label).toBe(`[${sessionNode.label.trim()}]: ${newLabel}`); }); + it("Should rename a dataset", async () => { + const sessionNode = testTree.mSessionNodes[1]; + const newLabel = "USER.NEW.LABEL"; + testTree.mFavorites = []; + const node = new ZoweDatasetNode("node", vscode.TreeItemCollapsibleState.Collapsed, sessionNode, null); + const checkSession = jest.spyOn(testTree, "rename"); + node.label = `[${sessionNode.label.trim()}]: ${node.label}`; + testTree.rename(node); + expect(checkSession).toHaveBeenCalledTimes(1); + + node.contextValue = "ds"; + testTree.rename(node); + expect(checkSession).toHaveBeenCalledTimes(2); + + node.contextValue = "ds_fav"; + testTree.rename(node); + // tslint:disable-next-line: no-magic-numbers + expect(checkSession).toHaveBeenCalledTimes(3); + + node.contextValue = "member"; + testTree.rename(node); + // tslint:disable-next-line: no-magic-numbers + expect(checkSession).toHaveBeenCalledTimes(4); + + node.contextValue = "member_fav"; + testTree.rename(node); + // tslint:disable-next-line: no-magic-numbers + expect(checkSession).toHaveBeenCalledTimes(5); + }); + it("Should rename a node", async () => { const sessionNode = testTree.mSessionNodes[1]; const newLabel = "USER.NEW.LABEL"; diff --git a/src/extension.ts b/src/extension.ts index f256a5bcaa..ab0c40ab37 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -681,22 +681,20 @@ export async function addZoweSession(zoweFileProvider: IZoweTree 0) { - quickpick.items = [createPick, ...items]; - quickpick.placeholder = placeholder; - quickpick.ignoreFocusOut = true; - quickpick.show(); - const choice = await utils.resolveQuickPickHelper(quickpick); - quickpick.hide(); - if (!choice) { - vscode.window.showInformationMessage(localize("enterPattern.pattern", "No selection made.")); - return; - } - if (choice instanceof utils.FilterDescriptor) { - chosenProfile = ""; - } else { - chosenProfile = choice.label; - } + quickpick.items = [createPick, ...items]; + quickpick.placeholder = placeholder; + quickpick.ignoreFocusOut = true; + quickpick.show(); + const choice = await utils.resolveQuickPickHelper(quickpick); + quickpick.hide(); + if (!choice) { + vscode.window.showInformationMessage(localize("enterPattern.pattern", "No selection made.")); + return; + } + if (choice instanceof utils.FilterDescriptor) { + chosenProfile = ""; + } else { + chosenProfile = choice.label; } } From 76383a78987862c860b71399e86b74f989af2e64 Mon Sep 17 00:00:00 2001 From: jellypuno Date: Fri, 13 Mar 2020 14:51:02 +0100 Subject: [PATCH 7/7] Revise tests Signed-off-by: jellypuno --- __tests__/__unit__/DatasetTree.unit.test.ts | 19 ++++++++++++++++++- __tests__/__unit__/Profiles.unit.test.ts | 8 ++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/__tests__/__unit__/DatasetTree.unit.test.ts b/__tests__/__unit__/DatasetTree.unit.test.ts index 595b39376e..11237f61af 100644 --- a/__tests__/__unit__/DatasetTree.unit.test.ts +++ b/__tests__/__unit__/DatasetTree.unit.test.ts @@ -719,7 +719,7 @@ describe("DatasetTree Unit Tests", () => { expect(testTree.mFavorites[0].label).toBe(`[${sessionNode.label.trim()}]: ${newLabel}`); }); - it("Should rename a dataset", async () => { + it("Should rename a PDS dataset", async () => { const sessionNode = testTree.mSessionNodes[1]; const newLabel = "USER.NEW.LABEL"; testTree.mFavorites = []; @@ -728,7 +728,15 @@ describe("DatasetTree Unit Tests", () => { node.label = `[${sessionNode.label.trim()}]: ${node.label}`; testTree.rename(node); expect(checkSession).toHaveBeenCalledTimes(1); + }); + it("Should rename a DS and DS_FAV dataset", async () => { + const sessionNode = testTree.mSessionNodes[1]; + const newLabel = "USER.NEW.LABEL"; + testTree.mFavorites = []; + const node = new ZoweDatasetNode("node", vscode.TreeItemCollapsibleState.Collapsed, sessionNode, null); + const checkSession = jest.spyOn(testTree, "rename"); + node.label = `[${sessionNode.label.trim()}]: ${node.label}`; node.contextValue = "ds"; testTree.rename(node); expect(checkSession).toHaveBeenCalledTimes(2); @@ -738,6 +746,15 @@ describe("DatasetTree Unit Tests", () => { // tslint:disable-next-line: no-magic-numbers expect(checkSession).toHaveBeenCalledTimes(3); + }); + + it("Should rename a Member and Member_FAV dataset", async () => { + const sessionNode = testTree.mSessionNodes[1]; + const newLabel = "USER.NEW.LABEL"; + testTree.mFavorites = []; + const node = new ZoweDatasetNode("node", vscode.TreeItemCollapsibleState.Collapsed, sessionNode, null); + const checkSession = jest.spyOn(testTree, "rename"); + node.label = `[${sessionNode.label.trim()}]: ${node.label}`; node.contextValue = "member"; testTree.rename(node); // tslint:disable-next-line: no-magic-numbers diff --git a/__tests__/__unit__/Profiles.unit.test.ts b/__tests__/__unit__/Profiles.unit.test.ts index 26fb9a471e..e9b4a0586d 100644 --- a/__tests__/__unit__/Profiles.unit.test.ts +++ b/__tests__/__unit__/Profiles.unit.test.ts @@ -278,9 +278,7 @@ describe("Profile class unit tests", () => { showInputBox.mockResolvedValueOnce("fake"); showInputBox.mockResolvedValueOnce("fake"); const res = await profiles.promptCredentials(promptProfile.name); - expect(res[0]).toBe("fake"); - expect(res[1]).toBe("fake"); - expect(res[2]).toBe("fake"); + expect(res).toEqual(["fake", "fake", "fake"]); (profiles.loadNamedProfile as any).mockReset(); }); @@ -299,9 +297,7 @@ describe("Profile class unit tests", () => { showInputBox.mockResolvedValueOnce("fake"); showInputBox.mockResolvedValueOnce("fake"); const res = await profiles.promptCredentials(promptProfile.name, true); - expect(res[0]).toBe("fake"); - expect(res[1]).toBe("fake"); - expect(res[2]).toBe("fake"); + expect(res).toEqual(["fake", "fake", "fake"]); (profiles.loadNamedProfile as any).mockReset(); });