From e6fb21e8af7f3eefadf31cc8e537fb6539104f3e Mon Sep 17 00:00:00 2001 From: Trae Yelovich Date: Wed, 13 Sep 2023 10:20:49 -0400 Subject: [PATCH] test(ftp): update test to ensure localFile isn't in object Signed-off-by: Trae Yelovich --- .../__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts b/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts index 2340ed9e71..ac8fcebdbb 100644 --- a/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts +++ b/packages/zowe-explorer-ftp-extension/__tests__/__unit__/Mvs/ZoweExplorerFtpMvsApi.unit.test.ts @@ -128,24 +128,27 @@ describe("FtpMvsApi", () => { fs.writeFileSync(localFile, ""); const response = TestUtils.getSingleLineStream(); - DataSetUtils.listDataSets = jest.fn().mockReturnValue([{ dsname: "IBMUSER.DS2", dsorg: "PS", lrecl: 2 }]); - DataSetUtils.uploadDataSet = jest.fn().mockReturnValue(response); + DataSetUtils.listDataSets = jest.fn().mockReturnValue([{ dsname: "USER.EMPTYDS", dsorg: "PS", lrecl: 2 }]); + const uploadDataSetMock = jest.fn().mockReturnValue(response); + DataSetUtils.uploadDataSet = uploadDataSetMock; jest.spyOn(MvsApi, "getContents").mockResolvedValue({ apiResponse: { etag: "123" } } as any); const mockParams = { inputFilePath: localFile, - dataSetName: " (IBMUSER).DS2", + dataSetName: "USER.EMPTYDS", options: { encoding: "", returnEtag: true, etag: "utf8" }, }; jest.spyOn(MvsApi as any, "getContentsTag").mockReturnValue(undefined); jest.spyOn(fs, "readFileSync").mockReturnValue(""); await MvsApi.putContents(mockParams.inputFilePath, mockParams.dataSetName, mockParams.options); - expect(DataSetUtils.uploadDataSet).toHaveBeenCalledWith({ host: "", password: "", port: "", user: "" }, " (IBMUSER).DS2", { + expect(DataSetUtils.uploadDataSet).toHaveBeenCalledWith({ host: "", password: "", port: "", user: "" }, "USER.EMPTYDS", { content: " ", encoding: "", transferType: "ascii", }); + // ensure options object at runtime does not have localFile + expect(Object.keys(uploadDataSetMock.mock.calls[0][2]).find((k) => k === "localFile")).toBe(undefined); expect(MvsApi.releaseConnection).toBeCalled(); });