Skip to content

Commit

Permalink
Handle DS findFavoritedNode when no matching profile node in Favorite…
Browse files Browse the repository at this point in the history
…s and add unit test

Signed-off-by: Lauren Li <45975633+lauren-li@users.noreply.github.com>
  • Loading branch information
lauren-li committed Sep 8, 2020
1 parent 8c01286 commit 264f165
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions __tests__/__unit__/dataset/DatasetTree.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 3 additions & 0 deletions src/dataset/DatasetTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ export class DatasetTree extends ZoweTreeProvider implements IZoweTree<IZoweData
// Get node's profile node in favorites
const profileName = node.getProfileName();
const profileNodeInFavorites = this.findMatchingProfileInArray(this.mFavorites, profileName);
if (!profileNodeInFavorites){
return;
}
return profileNodeInFavorites.children.find(
(temp) => (temp.label === node.getLabel()) && (temp.contextValue.includes(node.contextValue))
);
Expand Down

0 comments on commit 264f165

Please sign in to comment.