Skip to content

Commit

Permalink
Merge branch 'master' into Issue-370
Browse files Browse the repository at this point in the history
  • Loading branch information
jellypuno authored Mar 16, 2020
2 parents 76383a7 + f08214e commit 71c9f50
Show file tree
Hide file tree
Showing 3 changed files with 7,953 additions and 4,613 deletions.
56 changes: 54 additions & 2 deletions __tests__/__unit__/extension.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4083,7 +4083,7 @@ describe("Extension Unit Tests", () => {

showInputBox.mockReset();
renameDataSetMember.mockReset();
renameDataSetMember.mockImplementation(() => { throw defaultError; });
renameDataSetMember.mockImplementationOnce(() => { throw defaultError; });

const parent = new ZoweDatasetNode("HLQ.TEST.RENAME.NODE", vscode.TreeItemCollapsibleState.None, sessNode, null);
const child = new ZoweDatasetNode("mem1", vscode.TreeItemCollapsibleState.None, parent, null);
Expand All @@ -4101,6 +4101,57 @@ describe("Extension Unit Tests", () => {
expect(renameDataSetMember).toHaveBeenLastCalledWith(child.getSession(), "HLQ.TEST.RENAME.NODE", "mem1", "mem2");
expect(error).toBe(defaultError);
});
it("Should rename a favorited member and its matching non favorited node", async () => {
showInputBox.mockReset();
renameDataSet.mockReset();
renameDataSetMember.mockReset();
findNonFavoritedNode.mockReset();

const favoritedParent = new ZoweDatasetNode("[sesstest]: HLQ.TEST.RENAME.NODE", vscode.TreeItemCollapsibleState.None, sessNode, null);
const favoritedChild = new ZoweDatasetNode("mem1", vscode.TreeItemCollapsibleState.None, favoritedParent, null);
favoritedParent.children.push(favoritedChild);

const nonFavoritedParent = new ZoweDatasetNode("HLQ.TEST.RENAME.NODE", vscode.TreeItemCollapsibleState.None, sessNode, null);
const nonFavoritedChild = new ZoweDatasetNode("mem1", vscode.TreeItemCollapsibleState.None, nonFavoritedParent, null);
nonFavoritedParent.children.push(nonFavoritedChild);

findNonFavoritedNode.mockImplementationOnce(() => nonFavoritedParent);

favoritedParent.contextValue = extension.DS_PDS_CONTEXT + extension.FAV_SUFFIX;
favoritedChild.contextValue = extension.DS_MEMBER_CONTEXT;

showInputBox.mockResolvedValueOnce("mem2");
await extension.renameDataSetMember(favoritedChild, testTree);

expect(renameDataSetMember.mock.calls.length).toBe(1);
expect(nonFavoritedChild.label).toBe("mem2");
expect(renameDataSetMember).toHaveBeenLastCalledWith(favoritedChild.getSession(), "HLQ.TEST.RENAME.NODE", "mem1", "mem2");
});
it("Should rename a non favorited member and its matching favorited node", async () => {
showInputBox.mockReset();
renameDataSet.mockReset();
findFavoritedNode.mockReset();

const favoritedParent = new ZoweDatasetNode("[sesstest]: HLQ.TEST.RENAME.NODE", vscode.TreeItemCollapsibleState.None, sessNode, null);
const favoritedChild = new ZoweDatasetNode("mem1", vscode.TreeItemCollapsibleState.None, favoritedParent, null);
favoritedParent.children.push(favoritedChild);

const nonFavoritedParent = new ZoweDatasetNode("HLQ.TEST.RENAME.NODE", vscode.TreeItemCollapsibleState.None, sessNode, null);
const nonFavoritedChild = new ZoweDatasetNode("mem1", vscode.TreeItemCollapsibleState.None, nonFavoritedParent, null);
nonFavoritedParent.children.push(nonFavoritedChild);

findFavoritedNode.mockImplementationOnce(() => favoritedParent);

nonFavoritedParent.contextValue = extension.DS_PDS_CONTEXT;
nonFavoritedChild.contextValue = extension.DS_MEMBER_CONTEXT;

showInputBox.mockResolvedValueOnce("mem2");
await extension.renameDataSetMember(nonFavoritedChild, testTree);

expect(renameDataSetMember.mock.calls.length).toBe(1);
expect(favoritedChild.label).toBe("mem2");
expect(renameDataSetMember).toHaveBeenLastCalledWith(nonFavoritedChild.getSession(), "HLQ.TEST.RENAME.NODE", "mem1", "mem2");
});
});
describe("Copying Data Sets", () => {
it("Should copy the label of a node to the clipboard", async () => {
Expand Down Expand Up @@ -4237,6 +4288,7 @@ describe("Extension Unit Tests", () => {
expect(copyDataSet.mock.calls.length).toBe(0);
});
it("Should call zowe.Copy.dataSet when pasting to a favorited partitioned data set", async () => {
findNonFavoritedNode.mockReset();
jest.spyOn(mvsApi, "getContents").mockImplementation(() => {
throw Error("Member not found");
});
Expand All @@ -4250,7 +4302,7 @@ describe("Extension Unit Tests", () => {
favoritedNode.contextValue = extension.DS_PDS_CONTEXT + extension.FAV_SUFFIX;
const nonFavoritedNode = new ZoweDatasetNode("HLQ.TEST.TO.NODE", vscode.TreeItemCollapsibleState.None, sessNode, null,
undefined, undefined, profileOne);
findNonFavoritedNode.mockImplementation(() => nonFavoritedNode);
findNonFavoritedNode.mockImplementationOnce(() => nonFavoritedNode);

showInputBox.mockResolvedValueOnce("mem1");
clipboard.writeText(JSON.stringify({ dataSetName: "HLQ.TEST.BEFORE.NODE", profileName: "sestest" }));
Expand Down
Loading

0 comments on commit 71c9f50

Please sign in to comment.