Skip to content

Commit

Permalink
test: add coverage for added memberFound logic
Browse files Browse the repository at this point in the history
Signed-off-by: Fernando Rijo Cedeno <[email protected]>
  • Loading branch information
zFernand0 committed Jan 13, 2025
1 parent f31ccd9 commit 204e2ab
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,28 @@ describe("Dataset Actions Unit Tests - Function createMember", () => {
}
);
});

it("should not replace existing member when user cancels the replacement prompt", async () => {
const blockMocks = createBlockMocksShared();
const parent = new ZoweDatasetNode({
label: "parent",
collapsibleState: vscode.TreeItemCollapsibleState.Collapsed,
parentNode: blockMocks.datasetSessionNode,
session: blockMocks.session,
});

blockMocks.testDatasetTree.getChildren = jest.fn().mockResolvedValueOnce([{ ...parent, label: "TESTMEMBER" } as any] as any);

jest.spyOn(DatasetActions, "determineReplacement").mockResolvedValueOnce("cancel" as any);
mocked(vscode.window.showInputBox).mockResolvedValueOnce("TESTMEMBER");

jest.spyOn(DatasetFSProvider.instance, "fetchDatasetAtUri").mockResolvedValueOnce(true as any);

await DatasetActions.createMember(parent, blockMocks.testDatasetTree);

expect(vscode.commands.executeCommand).toHaveBeenCalledWith("vscode.open", { path: "/parent/parent/TESTMEMBER", scheme: "zowe-ds" });
expect(blockMocks.testDatasetTree.refresh).toHaveBeenCalled();
});
});

describe("Dataset Actions Unit Tests - Function refreshPS", () => {
Expand Down

0 comments on commit 204e2ab

Please sign in to comment.