diff --git a/__tests__/__unit__/dataset/DatasetTree.unit.test.ts b/__tests__/__unit__/dataset/DatasetTree.unit.test.ts index 9841102ce0..fea67317c3 100644 --- a/__tests__/__unit__/dataset/DatasetTree.unit.test.ts +++ b/__tests__/__unit__/dataset/DatasetTree.unit.test.ts @@ -1220,6 +1220,17 @@ describe("Dataset Tree Unit Tests - Function findFavoritedNode", () => { expect(foundNode).toBe(favoriteNode); }); + it("Checking that function does not error when there is no favorite or matching profile node in Favorites", async () => { + createGlobalMocks(); + const blockMocks = createBlockMocks(); + + mocked(vscode.window.createTreeView).mockReturnValueOnce(blockMocks.treeView); + const testTree = new DatasetTree(); + testTree.mSessionNodes.push(blockMocks.datasetSessionNode); + const node = new ZoweDatasetNode("node", vscode.TreeItemCollapsibleState.Collapsed, blockMocks.datasetSessionNode, null); + + expect(() => {testTree.findFavoritedNode(node);}).not.toThrow(); + }); }); describe("Dataset Tree Unit Tests - Function findNonFavoritedNode", () => { function createBlockMocks() { diff --git a/src/dataset/DatasetTree.ts b/src/dataset/DatasetTree.ts index f0037eb35a..0f91c28926 100644 --- a/src/dataset/DatasetTree.ts +++ b/src/dataset/DatasetTree.ts @@ -450,6 +450,9 @@ export class DatasetTree extends ZoweTreeProvider implements IZoweTree (temp.label === node.getLabel()) && (temp.contextValue.includes(node.contextValue)) );