diff --git a/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetActions.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetActions.unit.test.ts index adabd3327..7b12c46a6 100644 --- a/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetActions.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetActions.unit.test.ts @@ -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", () => {