From cc783316f83cea2cebcae2f2313e53d5d2996d5b Mon Sep 17 00:00:00 2001 From: Peter Moogk Date: Tue, 19 Nov 2024 15:59:05 -0500 Subject: [PATCH] Add unit tests for type info feature Signed-off-by: Peter Moogk --- .../trees/dataset/DatasetTree.unit.test.ts | 16 ++++++++++++++++ .../__unit__/trees/job/JobTree.unit.test.ts | 19 +++++++++++++++++++ .../__unit__/trees/uss/USSTree.unit.test.ts | 16 ++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetTree.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetTree.unit.test.ts index adf82a102..27bd2e1f0 100644 --- a/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetTree.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetTree.unit.test.ts @@ -1023,6 +1023,22 @@ describe("USSTree Unit Tests - Function addSingleSession", () => { expect(blockMocks.testTree.mSessionNodes.length).toEqual(2); }); + it("Tests that addSingleSession adds type info to the session", async () => { + const dsTree = new DatasetTree(); + const profile1 = await createIProfile(); + + profile1.name = "test1Profile"; + + await dsTree.addSingleSession(profile1); + + const sessionNode = dsTree.mSessionNodes.find((tNode) => tNode.label?.toString() === profile1.name) + + expect(sessionNode).toBeDefined(); + + const context = sessionNode?.contextValue; + expect(context).toContain("_type=zosmf"); + }); + it("Tests that addSingleSession successfully adds a session", async () => { await createGlobalMocks(); const blockMocks = await createBlockMocks(); diff --git a/packages/zowe-explorer/__tests__/__unit__/trees/job/JobTree.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/trees/job/JobTree.unit.test.ts index 3cbd4eba2..e2053fd82 100644 --- a/packages/zowe-explorer/__tests__/__unit__/trees/job/JobTree.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/trees/job/JobTree.unit.test.ts @@ -267,6 +267,25 @@ describe("ZosJobsProvider unit tests - Function getChildren", () => { return newMocks; } + it("Tests that addSingleSession adds type info to the session", async () => { + const globalMocks = await createGlobalMocks(); + const blockMocks = createBlockMocks(globalMocks); + mocked(vscode.window.createTreeView).mockReturnValueOnce(blockMocks.treeView); + const jobTree = new JobTree(); + const profile1 = await createIProfile(); + + profile1.name = "test1Profile"; + + await jobTree.addSingleSession(profile1); + + const sessionNode = jobTree.mSessionNodes.find((tNode) => tNode.label?.toString() === profile1.name) + + expect(sessionNode).toBeDefined(); + + const context = sessionNode?.contextValue; + expect(context).toContain("_type=zosmf"); + }); + it("Tests that getChildren returns the Favorites and sessions when called at the root node", async () => { const globalMocks = await createGlobalMocks(); const blockMocks = createBlockMocks(globalMocks); diff --git a/packages/zowe-explorer/__tests__/__unit__/trees/uss/USSTree.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/trees/uss/USSTree.unit.test.ts index 313907320..27192f7d1 100644 --- a/packages/zowe-explorer/__tests__/__unit__/trees/uss/USSTree.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/trees/uss/USSTree.unit.test.ts @@ -1178,6 +1178,22 @@ describe("USSTree Unit Tests - Function addSingleSession", () => { expect(globalMocks.testTree.mSessionNodes.length).toEqual(2); }); + it("Tests that addSingleSession adds type info to the session", async () => { + const ussTree = new USSTree(); + const profile1 = await createIProfile(); + + profile1.name = "test1Profile"; + + await ussTree.addSingleSession(profile1); + + const sessionNode = ussTree.mSessionNodes.find((tNode) => tNode.label?.toString() === profile1.name) + + expect(sessionNode).toBeDefined(); + + const context = sessionNode?.contextValue; + expect(context).toContain("_type=zosmf"); + }); + it("Tests that addSingleSession successfully adds a session", async () => { const globalMocks = createGlobalMocks();