diff --git a/packages/zowe-explorer-api/__tests__/__unit__/globals/Gui.unit.test.ts b/packages/zowe-explorer-api/__tests__/__unit__/globals/Gui.unit.test.ts index 28a11d19cc..a8382a571a 100644 --- a/packages/zowe-explorer-api/__tests__/__unit__/globals/Gui.unit.test.ts +++ b/packages/zowe-explorer-api/__tests__/__unit__/globals/Gui.unit.test.ts @@ -22,7 +22,7 @@ function createGlobalMocks() { showWarningMessage: jest.fn(), createOutputChannel: jest.fn(), createQuickPick: jest.fn(), - createTreeView: jest.fn(), + createTreeView: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), createWebviewPanel: jest.fn(), withProgress: jest.fn(), showTextDocument: jest.fn(), diff --git a/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts index 2876032d7b..5309decf5a 100644 --- a/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/Profiles.extended.unit.test.ts @@ -112,7 +112,10 @@ async function createGlobalMocks() { configurable: true, }); Object.defineProperty(globals, "ISTHEIA", { get: () => false, configurable: true }); - Object.defineProperty(vscode.window, "createTreeView", { value: jest.fn(), configurable: true }); + Object.defineProperty(vscode.window, "createTreeView", { + value: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), + configurable: true, + }); Object.defineProperty(vscode.workspace, "getConfiguration", { value: newMocks.mockGetConfiguration, configurable: true, diff --git a/packages/zowe-explorer/__tests__/__unit__/ZoweExplorerExtender.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/ZoweExplorerExtender.unit.test.ts index 6ae337f750..34cbb87bb6 100644 --- a/packages/zowe-explorer/__tests__/__unit__/ZoweExplorerExtender.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/ZoweExplorerExtender.unit.test.ts @@ -53,7 +53,10 @@ describe("ZoweExplorerExtender unit tests", () => { }) .mockReturnValue(newMocks.profiles), }); - Object.defineProperty(vscode.window, "createTreeView", { value: jest.fn(), configurable: true }); + Object.defineProperty(vscode.window, "createTreeView", { + value: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), + configurable: true, + }); Object.defineProperty(vscode.window, "showErrorMessage", { value: newMocks.mockErrorMessage, configurable: true, diff --git a/packages/zowe-explorer/__tests__/__unit__/abstract/TreeProvider.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/abstract/TreeProvider.unit.test.ts index 096d54cf5b..0771a57f74 100644 --- a/packages/zowe-explorer/__tests__/__unit__/abstract/TreeProvider.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/abstract/TreeProvider.unit.test.ts @@ -37,7 +37,7 @@ async function createGlobalMocks() { mockLoadNamedProfile: jest.fn(), mockDefaultProfile: jest.fn(), withProgress: jest.fn(), - createTreeView: jest.fn(), + createTreeView: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), mockAffects: jest.fn(), mockEditSession: jest.fn(), mockCheckCurrentProfile: jest.fn(), diff --git a/packages/zowe-explorer/__tests__/__unit__/abstract/ZoweSaveQueue.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/abstract/ZoweSaveQueue.unit.test.ts index 048fb60b96..d50db952a2 100644 --- a/packages/zowe-explorer/__tests__/__unit__/abstract/ZoweSaveQueue.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/abstract/ZoweSaveQueue.unit.test.ts @@ -20,6 +20,7 @@ import { ZoweLogger } from "../../../src/utils/LoggerUtils"; describe("ZoweSaveQueue - unit tests", () => { const createGlobalMocks = () => { + jest.spyOn(Gui, "createTreeView").mockReturnValue({ onDidCollapseElement: jest.fn() } as any); const globalMocks = { errorMessageSpy: jest.spyOn(Gui, "errorMessage"), markDocumentUnsavedSpy: jest.spyOn(workspaceUtils, "markDocumentUnsaved"), diff --git a/packages/zowe-explorer/__tests__/__unit__/dataset/DatasetTree.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/dataset/DatasetTree.unit.test.ts index 9cb5357619..42d3a43fc0 100644 --- a/packages/zowe-explorer/__tests__/__unit__/dataset/DatasetTree.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/dataset/DatasetTree.unit.test.ts @@ -59,7 +59,10 @@ function createGlobalMocks() { globalMocks.mockProfileInstance = createInstanceOfProfile(globalMocks.testProfileLoaded); - Object.defineProperty(vscode.window, "createTreeView", { value: jest.fn(), configurable: true }); + Object.defineProperty(vscode.window, "createTreeView", { + value: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), + configurable: true, + }); Object.defineProperty(Gui, "showMessage", { value: jest.fn(), configurable: true }); Object.defineProperty(Gui, "setStatusBarMessage", { value: jest.fn().mockReturnValue({ dispose: jest.fn() }), configurable: true }); Object.defineProperty(vscode.window, "showTextDocument", { value: jest.fn(), configurable: true }); diff --git a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts index 1b8e377e58..f038b1e853 100644 --- a/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/extension.unit.test.ts @@ -45,7 +45,7 @@ async function createGlobalMocks() { mockMoveSync: jest.fn(), mockGetAllProfileNames: jest.fn(), mockReveal: jest.fn(), - mockCreateTreeView: jest.fn(), + mockCreateTreeView: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), mockExecuteCommand: jest.fn(), mockRegisterCommand: jest.fn(), mockOnDidSaveTextDocument: jest.fn(), diff --git a/packages/zowe-explorer/__tests__/__unit__/generators/icons.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/generators/icons.unit.test.ts index 957c70970c..c9ec8046f2 100644 --- a/packages/zowe-explorer/__tests__/__unit__/generators/icons.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/generators/icons.unit.test.ts @@ -19,7 +19,7 @@ import * as vscode from "vscode"; describe("Checking icon generator's basics", () => { const setGlobalMocks = () => { - const createTreeView = jest.fn(); + const createTreeView = jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }); const getConfiguration = jest.fn(); Object.defineProperty(vscode.window, "createTreeView", { value: createTreeView }); diff --git a/packages/zowe-explorer/__tests__/__unit__/generators/messages.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/generators/messages.unit.test.ts index 2b46ac7d6a..a4fd28edc8 100644 --- a/packages/zowe-explorer/__tests__/__unit__/generators/messages.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/generators/messages.unit.test.ts @@ -19,7 +19,7 @@ jest.mock("vscode"); describe("Checking message generator's basics", () => { const setGlobalMocks = () => { - const createTreeView = jest.fn(); + const createTreeView = jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }); const getConfiguration = jest.fn(); Object.defineProperty(vscode.window, "createTreeView", { value: createTreeView }); diff --git a/packages/zowe-explorer/__tests__/__unit__/job/ZosJobsProvider.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/job/ZosJobsProvider.unit.test.ts index da5b74ffa7..7965f68cef 100644 --- a/packages/zowe-explorer/__tests__/__unit__/job/ZosJobsProvider.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/job/ZosJobsProvider.unit.test.ts @@ -45,7 +45,7 @@ async function createGlobalMocks() { mockGetJob: jest.fn(), mockRefresh: jest.fn(), mockAffectsConfig: jest.fn(), - createTreeView: jest.fn(), + createTreeView: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), mockGetSpoolFiles: jest.fn(), mockDeleteJobs: jest.fn(), mockShowInputBox: jest.fn(), @@ -85,7 +85,7 @@ async function createGlobalMocks() { }; }), }; - + jest.spyOn(Gui, "createTreeView").mockImplementation(globalMocks.createTreeView); Object.defineProperty(ProfilesCache, "getConfigInstance", { value: jest.fn(() => { return { @@ -173,7 +173,6 @@ async function createGlobalMocks() { Object.defineProperty(ZoweLogger, "warn", { value: jest.fn(), configurable: true }); Object.defineProperty(ZoweLogger, "info", { value: jest.fn(), configurable: true }); Object.defineProperty(ZoweLogger, "trace", { value: jest.fn(), configurable: true }); - globalMocks.createTreeView.mockReturnValue("testTreeView"); globalMocks.testSessionNode = createJobSessionNode(globalMocks.testSession, globalMocks.testProfile); globalMocks.mockGetJob.mockReturnValue(globalMocks.testIJob); globalMocks.mockGetJobsByOwnerAndPrefix.mockReturnValue([globalMocks.testIJob, globalMocks.testIJobComplete]); diff --git a/packages/zowe-explorer/__tests__/__unit__/job/ZoweJobNode.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/job/ZoweJobNode.unit.test.ts index 2ab7070292..554aaf2670 100644 --- a/packages/zowe-explorer/__tests__/__unit__/job/ZoweJobNode.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/job/ZoweJobNode.unit.test.ts @@ -40,6 +40,7 @@ async function createGlobalMocks() { mockAffectsConfig: jest.fn(), createTreeView: jest.fn(() => ({ reveal: jest.fn(), + onDidCollapseElement: jest.fn(), })), mockCreateSessCfgFromArgs: jest.fn(), mockGetSpoolFiles: jest.fn(), diff --git a/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts index 0c6847479e..2df3701b7d 100644 --- a/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/job/actions.unit.test.ts @@ -45,6 +45,7 @@ import { SpoolFile } from "../../../src/SpoolProvider"; const activeTextEditorDocument = jest.fn(); function createGlobalMocks() { + jest.spyOn(Gui, "createTreeView").mockReturnValue({ onDidCollapseElement: jest.fn() } as any); Object.defineProperty(vscode.workspace, "getConfiguration", { value: jest.fn().mockImplementation(() => new Map([["zowe.jobs.confirmSubmission", false]])), configurable: true, diff --git a/packages/zowe-explorer/__tests__/__unit__/shared/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/shared/actions.unit.test.ts index 51e6c042a8..aec9ead9cf 100644 --- a/packages/zowe-explorer/__tests__/__unit__/shared/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/shared/actions.unit.test.ts @@ -69,7 +69,10 @@ async function createGlobalMocks() { }), configurable: true, }); - Object.defineProperty(vscode.window, "createTreeView", { value: jest.fn(), configurable: true }); + Object.defineProperty(vscode.window, "createTreeView", { + value: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), + configurable: true, + }); Object.defineProperty(vscode.workspace, "getConfiguration", { value: jest.fn(), configurable: true }); Object.defineProperty(vscode.window, "showInformationMessage", { value: jest.fn(), configurable: true }); Object.defineProperty(vscode.window, "showInputBox", { value: jest.fn(), configurable: true }); diff --git a/packages/zowe-explorer/__tests__/__unit__/shared/refresh.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/shared/refresh.unit.test.ts index f306801e88..7dc0661da9 100644 --- a/packages/zowe-explorer/__tests__/__unit__/shared/refresh.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/shared/refresh.unit.test.ts @@ -31,7 +31,7 @@ import { ZoweLogger } from "../../../src/utils/LoggerUtils"; function createGlobalMocks() { const globalMocks = { session: createISessionWithoutCredentials(), - createTreeView: jest.fn(), + createTreeView: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), mockLog: jest.fn(), mockDebug: jest.fn(), mockError: jest.fn(), diff --git a/packages/zowe-explorer/__tests__/__unit__/uss/USSTree.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/uss/USSTree.unit.test.ts index 56d20ad5b0..8de2e871ab 100644 --- a/packages/zowe-explorer/__tests__/__unit__/uss/USSTree.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/uss/USSTree.unit.test.ts @@ -47,7 +47,7 @@ async function createGlobalMocks() { showInputBox: jest.fn(), filters: jest.fn(), getFilters: jest.fn(), - createTreeView: jest.fn(), + createTreeView: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), createQuickPick: jest.fn(), getConfiguration: jest.fn(), ZosmfSession: jest.fn(), diff --git a/packages/zowe-explorer/__tests__/__unit__/uss/ZoweUSSNode.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/uss/ZoweUSSNode.unit.test.ts index b80a6805f3..1a02dc1ea2 100644 --- a/packages/zowe-explorer/__tests__/__unit__/uss/ZoweUSSNode.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/uss/ZoweUSSNode.unit.test.ts @@ -137,7 +137,10 @@ async function createGlobalMocks() { configurable: true, }); Object.defineProperty(vscode.window, "showInputBox", { value: globalMocks.showInputBox, configurable: true }); - Object.defineProperty(vscode.window, "createTreeView", { value: jest.fn(), configurable: true }); + Object.defineProperty(vscode.window, "createTreeView", { + value: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), + configurable: true, + }); Object.defineProperty(zowe, "ZosmfSession", { value: globalMocks.ZosmfSession, configurable: true }); Object.defineProperty(globalMocks.ZosmfSession, "createSessCfgFromArgs", { value: globalMocks.createSessCfgFromArgs, diff --git a/packages/zowe-explorer/__tests__/__unit__/uss/actions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/uss/actions.unit.test.ts index 797f1ee46b..4d054e113a 100644 --- a/packages/zowe-explorer/__tests__/__unit__/uss/actions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/uss/actions.unit.test.ts @@ -60,7 +60,7 @@ function createGlobalMocks() { setStatusBarMessage: jest.fn().mockReturnValue({ dispose: jest.fn() }), showWarningMessage: jest.fn(), showErrorMessage: jest.fn(), - createTreeView: jest.fn(), + createTreeView: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), fileToUSSFile: jest.fn(), Upload: jest.fn(), isBinaryFileSync: jest.fn(), diff --git a/packages/zowe-explorer/__tests__/__unit__/utils/SessionUtils.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/utils/SessionUtils.unit.test.ts index c97166e6de..4925d06b58 100644 --- a/packages/zowe-explorer/__tests__/__unit__/utils/SessionUtils.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/utils/SessionUtils.unit.test.ts @@ -29,7 +29,10 @@ describe("SessionUtils removeSession Unit Tests", () => { newMocks.datasetSessionNode = createDatasetSessionNode(newMocks.session, newMocks.imperativeProfile); newMocks.testDatasetTree = createDatasetTree(newMocks.datasetSessionNode, newMocks.treeView); newMocks.testDatasetTree.addFileHistory("[profile1]: TEST.NODE"); - Object.defineProperty(vscode.window, "createTreeView", { value: jest.fn(), configurable: true }); + Object.defineProperty(vscode.window, "createTreeView", { + value: jest.fn().mockReturnValue({ onDidCollapseElement: jest.fn() }), + configurable: true, + }); Object.defineProperty(vscode, "ConfigurationTarget", { value: jest.fn(), configurable: true }); newMocks.mockGetConfiguration.mockReturnValue(createPersistentConfig()); Object.defineProperty(vscode.workspace, "getConfiguration", {