Skip to content

Commit

Permalink
test(ftp): update test to ensure localFile isn't in object
Browse files Browse the repository at this point in the history
Signed-off-by: Trae Yelovich <[email protected]>
  • Loading branch information
traeok committed Sep 13, 2023
1 parent 679bfc9 commit e6fb21e
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down

0 comments on commit e6fb21e

Please sign in to comment.