From 124fbb7bc5f88ae9864aeb14d1dca0e724526964 Mon Sep 17 00:00:00 2001 From: zFernand0 <37381190+zFernand0@users.noreply.github.com> Date: Tue, 12 Sep 2023 21:11:59 +0000 Subject: [PATCH] down to 524 errors, mostly related to types.jest Signed-off-by: zFernand0 <37381190+zFernand0@users.noreply.github.com> --- gulp/DevelopmentTasks.ts | 4 +- npm-shrinkwrap.json | 36 +++- package.json | 2 +- packages/cli/scripts/printSuccessMessage.js | 24 ++- packages/imperative/package.json | 2 +- .../src/logger/__tests__/Logger.test.ts | 26 +-- .../rest/__tests__/client/RestClient.test.ts | 8 +- .../src/client/doc/IRestClientResponse.ts | 5 + packages/imperative/web-help/dist/js/docs.js | 3 +- packages/imperative/web-help/dist/js/tree.js | 3 +- .../__unit__/DeleteInstance.unit.test.ts | 2 +- .../ListCatalogTemplates.unit.test.ts | 2 +- .../__unit__/ListInstanceInfo.unit.test.ts | 2 +- .../ListInstanceVariables.unit.test.ts | 2 +- .../ListRegistryInstances.unit.test.ts | 10 +- .../__unit__/ListTemplateInfo.unit.test.ts | 2 +- .../__unit__/PerformAction.unit.test.ts | 2 +- .../ProvisionPublishedTemplate.unit.test.ts | 6 +- .../__tests__/__unit__/Archive.unit.test.ts | 14 +- .../__unit__/ArchivedDelete.unit.test.ts | 4 +- .../__tests__/__unit__/Cancel.unit.test.ts | 4 +- .../__tests__/__unit__/Create.unit.test.ts | 32 ++-- .../__unit__/Definition.unit.test.ts | 18 +- .../__tests__/__unit__/Delete.unit.test.ts | 4 +- .../ListArchivedWorkflows.unit.test.ts | 2 +- .../__unit__/ListWorkflows.unit.test.ts | 10 +- .../__unit__/Properties.unit.test.ts | 18 +- .../__tests__/__unit__/Start.unit.test.ts | 6 +- .../__unit__/CollectCommand.unit.test.ts | 18 +- .../__unit__/IssueCommand.unit.test.ts | 34 ++-- .../methods/upload/Upload.unit.test.ts | 166 +++++++++--------- .../methods/utilities/Utilities.unit.test.ts | 26 +-- .../__unit__/utils/ZosFilesUtils.unit.test.ts | 16 +- .../__system__/MonitorJobs.system.test.ts | 10 +- .../__unit__/CancelJobs.unit.test.ts | 42 ++--- .../__unit__/DeleteJobs.unit.test.ts | 18 +- .../__unit__/DownloadJobs.unit.test.ts | 24 +-- .../__tests__/__unit__/GetJobs.unit.test.ts | 28 +-- .../__tests__/__unit__/MonitorJobs.test.ts | 68 +++---- .../__unit__/MonitorJobs.unit.test.ts | 18 +- .../__unit__/SubmitJobs.unit.test.ts | 18 +- .../__tests__/__unit__/GetZosLog.unit.test.ts | 4 +- .../__tests__/__unit__/IssueTso.unit.test.ts | 12 +- .../__tests__/__unit__/PingTso.unit.test.ts | 4 +- .../__tests__/__unit__/SendTso.unit.test.ts | 6 +- .../__tests__/__unit__/StartTso.unit.test.ts | 12 +- .../__tests__/__unit__/StopTso.unit.test.ts | 6 +- 47 files changed, 416 insertions(+), 367 deletions(-) diff --git a/gulp/DevelopmentTasks.ts b/gulp/DevelopmentTasks.ts index c1e068e70e..cf8bfb300e 100644 --- a/gulp/DevelopmentTasks.ts +++ b/gulp/DevelopmentTasks.ts @@ -285,7 +285,7 @@ const buildAllClis: ITaskFunction = async () => { // Build them all fancylog(`Build "${dir}" cli...`); const buildResponse = childProcess.spawnSync((process.platform === "win32") ? "npm.cmd" : "npm", ["run", "build"], - {cwd: imperativeDirectory + `__tests__/__integration__/${dir}/`}); + {cwd: imperativeDirectory + `__tests__/__integration__/${dir}/`, stdio: "inherit"}); if (buildResponse.stdout && buildResponse.stdout.toString().length > 0) { fancylog(`***BUILD "${dir}" stdout:\n${buildResponse.stdout.toString()}`); } @@ -312,7 +312,7 @@ const installAllCliDependencies: ITaskFunction = async () => { // Perform an NPM install fancylog(`Executing "npm install" for "${dir}" cli to obtain dependencies...`); const installResponse = childProcess.spawnSync((process.platform === "win32") ? "npm.cmd" : "npm", ["install"], - {cwd: imperativeDirectory + `__tests__/__integration__/${dir}/`}); + {cwd: imperativeDirectory + `__tests__/__integration__/${dir}/`, stdio: "inherit"}); if (installResponse.stdout && installResponse.stdout.toString().length > 0) { fancylog(`***INSTALL "${dir}" stdout:\n${installResponse.stdout.toString()}`); } diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index ab4e133f2d..ea79800c16 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -15,7 +15,7 @@ "devDependencies": { "@octorelease/lerna": "^0.1.4", "@types/fs-extra": "^8.0.1", - "@types/jest": "^22.0.0", + "@types/jest": "^24.9.1", "@types/lodash": "4.14.175", "@types/node": "^12.20.23", "@typescript-eslint/eslint-plugin": "^4.29.0", @@ -7525,10 +7525,13 @@ } }, "node_modules/@types/jest": { - "version": "22.2.3", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-22.2.3.tgz", - "integrity": "sha512-e74sM9W/4qqWB6D4TWV9FQk0WoHtX1X4FJpbjxucMSVJHtFjbQOH3H6yp+xno4br0AKG0wz/kPtaN599GUOvAg==", - "dev": true + "version": "24.9.1", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.9.1.tgz", + "integrity": "sha512-Fb38HkXSVA4L8fGKEZ6le5bB8r6MRWlOCZbVuWZcmOMSCd2wCYOwN1ibj8daIoV9naq7aaOZjrLCoCMptKU/4Q==", + "dev": true, + "dependencies": { + "jest-diff": "^24.3.0" + } }, "node_modules/@types/jquery": { "version": "3.5.18", @@ -29328,6 +29331,12 @@ "node": ">=8.0.0" } }, + "packages/imperative/node_modules/@types/jest": { + "version": "22.2.3", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-22.2.3.tgz", + "integrity": "sha512-e74sM9W/4qqWB6D4TWV9FQk0WoHtX1X4FJpbjxucMSVJHtFjbQOH3H6yp+xno4br0AKG0wz/kPtaN599GUOvAg==", + "dev": true + }, "packages/imperative/node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -35930,10 +35939,13 @@ } }, "@types/jest": { - "version": "22.2.3", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-22.2.3.tgz", - "integrity": "sha512-e74sM9W/4qqWB6D4TWV9FQk0WoHtX1X4FJpbjxucMSVJHtFjbQOH3H6yp+xno4br0AKG0wz/kPtaN599GUOvAg==", - "dev": true + "version": "24.9.1", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.9.1.tgz", + "integrity": "sha512-Fb38HkXSVA4L8fGKEZ6le5bB8r6MRWlOCZbVuWZcmOMSCd2wCYOwN1ibj8daIoV9naq7aaOZjrLCoCMptKU/4Q==", + "dev": true, + "requires": { + "jest-diff": "^24.3.0" + } }, "@types/jquery": { "version": "3.5.18", @@ -36525,6 +36537,12 @@ "yargs-parser": "^18.1.2" }, "dependencies": { + "@types/jest": { + "version": "22.2.3", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-22.2.3.tgz", + "integrity": "sha512-e74sM9W/4qqWB6D4TWV9FQk0WoHtX1X4FJpbjxucMSVJHtFjbQOH3H6yp+xno4br0AKG0wz/kPtaN599GUOvAg==", + "dev": true + }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", diff --git a/package.json b/package.json index a41fe2e8c7..71273e3388 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "devDependencies": { "@octorelease/lerna": "^0.1.4", "@types/fs-extra": "^8.0.1", - "@types/jest": "^22.0.0", + "@types/jest": "^24.9.1", "@types/lodash": "4.14.175", "@types/node": "^12.20.23", "@typescript-eslint/eslint-plugin": "^4.29.0", diff --git a/packages/cli/scripts/printSuccessMessage.js b/packages/cli/scripts/printSuccessMessage.js index 809a602c65..8549d32a54 100644 --- a/packages/cli/scripts/printSuccessMessage.js +++ b/packages/cli/scripts/printSuccessMessage.js @@ -33,4 +33,26 @@ function printSuccessMessage() { console.log("\n" + table + "\n"); } -printSuccessMessage(); \ No newline at end of file +// printSuccessMessage(); +const installSuccessMessage = + "Zowe CLI has been successfully installed. " + + "You can safely ignore all non-plug-in related errors and warnings. " + + "Please check above for any plug-in related issues."; +const Table = require("cli-table3"); +const table = new Table({ + chars: { + top: "═", + "top-left": "╔", + "top-right": "╗", + bottom: "═", + "bottom-left": "╚", + "bottom-right": "╝", + left: "║", + right: "║", + }, + colWidths: [require("yargs").terminalWidth() - 8], + style: { "padding-left": 0, "padding-right": 0, head: [], border: [] }, + wordWrap: true, +}); +table.push([installSuccessMessage]); +console.log("\n" + table.toString() + "\n"); \ No newline at end of file diff --git a/packages/imperative/package.json b/packages/imperative/package.json index cd6bcdefb2..8ea5e128b2 100644 --- a/packages/imperative/package.json +++ b/packages/imperative/package.json @@ -40,7 +40,7 @@ "build": "npm run build:packages && npm run build:webHelp", "build:packages": "tsc --pretty", "watch": "gulp watchImperative", - "postbuild": "gulp build:install-all-cli-dependencies && gulp build:all-clis" + "postbuild": "gulp build:install-all-cli-dependencies --stdio=inherit && gulp build:all-clis --stdio=inherit" }, "dependencies": { "@types/yargs": "13.0.4", diff --git a/packages/imperative/src/logger/__tests__/Logger.test.ts b/packages/imperative/src/logger/__tests__/Logger.test.ts index b1f5b4b93e..6c22932c78 100644 --- a/packages/imperative/src/logger/__tests__/Logger.test.ts +++ b/packages/imperative/src/logger/__tests__/Logger.test.ts @@ -28,7 +28,7 @@ describe("Logger tests", () => { const name = "sample"; // // // This needs to be mocked before running process function of uninstall handler - // (Logger as any).writeToLog = jest.fn((data: string) => data); + // (Logger as any).writeToLog = jest.fn((data: string) => data); beforeAll(() => { let configuration: ILog4jsConfig; @@ -80,12 +80,12 @@ describe("Logger tests", () => { const config = LoggingConfigurer.configureLogger(fakeHome, {name}); const logger = Logger.initLogger(config); - (logger as any).logService.trace = jest.fn((data: string) => data); - (logger as any).logService.info = jest.fn((data: string) => data); - (logger as any).logService.debug = jest.fn((data: string) => data); - (logger as any).logService.warn = jest.fn((data: string) => data); - (logger as any).logService.error = jest.fn((data: string) => data); - (logger as any).logService.fatal = jest.fn((data: string) => data); + (logger as any).logService.trace = jest.fn((data: string) => data); + (logger as any).logService.info = jest.fn((data: string) => data); + (logger as any).logService.debug = jest.fn((data: string) => data); + (logger as any).logService.warn = jest.fn((data: string) => data); + (logger as any).logService.error = jest.fn((data: string) => data); + (logger as any).logService.fatal = jest.fn((data: string) => data); logger.trace("message"); logger.info("test"); @@ -165,12 +165,12 @@ describe("Logger tests", () => { const config = LoggingConfigurer.configureLogger(fakeHome, {name}); const logger = Logger.initLogger(config); - (logger as any).logService.trace = jest.fn((data: string) => data); - (logger as any).logService.info = jest.fn((data: string) => data); - (logger as any).logService.debug = jest.fn((data: string) => data); - (logger as any).logService.warn = jest.fn((data: string) => data); - (logger as any).logService.error = jest.fn((data: string) => data); - (logger as any).logService.fatal = jest.fn((data: string) => data); + (logger as any).logService.trace = jest.fn((data: string) => data); + (logger as any).logService.info = jest.fn((data: string) => data); + (logger as any).logService.debug = jest.fn((data: string) => data); + (logger as any).logService.warn = jest.fn((data: string) => data); + (logger as any).logService.error = jest.fn((data: string) => data); + (logger as any).logService.fatal = jest.fn((data: string) => data); const error = new ImperativeError({msg: "sample error"}); diff --git a/packages/imperative/src/rest/__tests__/client/RestClient.test.ts b/packages/imperative/src/rest/__tests__/client/RestClient.test.ts index 558dba56b7..dac268bcbc 100644 --- a/packages/imperative/src/rest/__tests__/client/RestClient.test.ts +++ b/packages/imperative/src/rest/__tests__/client/RestClient.test.ts @@ -268,7 +268,7 @@ describe("RestClient tests", () => { expect(error).toBeUndefined(); expect(response).toBeDefined(); expect(response.data).toEqual(Buffer.concat([randomBytes1, randomBytes2])); - listOfClientProperties.forEach((property) => expect(response[`${property}`]).toBeDefined()); + listOfClientProperties.forEach((property) => expect(response[property]).toBeDefined()); randomBytes1 = await getRandomBytes(randomByteLength); randomBytes2 = await getRandomBytes(randomByteLength); @@ -280,7 +280,7 @@ describe("RestClient tests", () => { expect(error).toBeUndefined(); expect(response).toBeDefined(); expect(response.data).toEqual(Buffer.concat([randomBytes1, randomBytes2])); - listOfClientProperties.forEach((property) => expect(response[`${property}`]).toBeDefined()); + listOfClientProperties.forEach((property) => expect(response[property]).toBeDefined()); randomBytes1 = await getRandomBytes(randomByteLength); randomBytes2 = await getRandomBytes(randomByteLength); @@ -292,7 +292,7 @@ describe("RestClient tests", () => { expect(error).toBeUndefined(); expect(response).toBeDefined(); expect(response.data).toEqual(Buffer.concat([randomBytes1, randomBytes2])); - listOfClientProperties.forEach((property) => expect(response[`${property}`]).toBeDefined()); + listOfClientProperties.forEach((property) => expect(response[property]).toBeDefined()); randomBytes1 = await getRandomBytes(randomByteLength); randomBytes2 = await getRandomBytes(randomByteLength); @@ -304,7 +304,7 @@ describe("RestClient tests", () => { expect(error).toBeUndefined(); expect(response).toBeDefined(); expect(response.data).toEqual(Buffer.concat([randomBytes1, randomBytes2])); - listOfClientProperties.forEach((property) => expect(response[`${property}`]).toBeDefined()); + listOfClientProperties.forEach((property) => expect(response[property]).toBeDefined()); }); }); diff --git a/packages/imperative/src/rest/src/client/doc/IRestClientResponse.ts b/packages/imperative/src/rest/src/client/doc/IRestClientResponse.ts index 1bd4c3850e..5c9978dc90 100644 --- a/packages/imperative/src/rest/src/client/doc/IRestClientResponse.ts +++ b/packages/imperative/src/rest/src/client/doc/IRestClientResponse.ts @@ -69,4 +69,9 @@ export interface IRestClientResponse { * @memberof IRestClientResponse */ log?: Logger; + + /** + * This is for convenient programmatic access to properties in this interface + */ + [key: string]: any } diff --git a/packages/imperative/web-help/dist/js/docs.js b/packages/imperative/web-help/dist/js/docs.js index 7bcc517502..4e35002f40 100644 --- a/packages/imperative/web-help/dist/js/docs.js +++ b/packages/imperative/web-help/dist/js/docs.js @@ -1,4 +1,3 @@ -"use strict"; /* * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at @@ -9,6 +8,8 @@ * Copyright Contributors to the Zowe Project. * */ + +"use strict"; // Array.from polyfill for IE11 support function arrayFrom(items) { if (typeof Array.from === "function") { diff --git a/packages/imperative/web-help/dist/js/tree.js b/packages/imperative/web-help/dist/js/tree.js index 1fa57028a0..520175ec23 100644 --- a/packages/imperative/web-help/dist/js/tree.js +++ b/packages/imperative/web-help/dist/js/tree.js @@ -1,4 +1,3 @@ -"use strict"; /* * This program and the accompanying materials are made available under the terms of the * Eclipse Public License v2.0 which accompanies this distribution, and is available at @@ -9,6 +8,8 @@ * Copyright Contributors to the Zowe Project. * */ + +"use strict"; var __spreadArrays = (this && this.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) diff --git a/packages/provisioning/__tests__/__unit__/DeleteInstance.unit.test.ts b/packages/provisioning/__tests__/__unit__/DeleteInstance.unit.test.ts index c9572f6130..dc9f8c5d8b 100644 --- a/packages/provisioning/__tests__/__unit__/DeleteInstance.unit.test.ts +++ b/packages/provisioning/__tests__/__unit__/DeleteInstance.unit.test.ts @@ -47,7 +47,7 @@ describe("DeleteInstance deleteDeprovisionedInstance", () => { it("should succeed with all correct parameters", async () => { - (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { + (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { return ""; }); diff --git a/packages/provisioning/__tests__/__unit__/ListCatalogTemplates.unit.test.ts b/packages/provisioning/__tests__/__unit__/ListCatalogTemplates.unit.test.ts index 34cd80d738..03fc48e128 100644 --- a/packages/provisioning/__tests__/__unit__/ListCatalogTemplates.unit.test.ts +++ b/packages/provisioning/__tests__/__unit__/ListCatalogTemplates.unit.test.ts @@ -97,7 +97,7 @@ function expectZosmfResponseFailed(response: IPublishedTemplates, error: Imperat describe("ListCatalogTemplates listCatalogCommon", () => { it("should succeed with all correctly provided parameters", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); diff --git a/packages/provisioning/__tests__/__unit__/ListInstanceInfo.unit.test.ts b/packages/provisioning/__tests__/__unit__/ListInstanceInfo.unit.test.ts index c960781114..f708b584dd 100644 --- a/packages/provisioning/__tests__/__unit__/ListInstanceInfo.unit.test.ts +++ b/packages/provisioning/__tests__/__unit__/ListInstanceInfo.unit.test.ts @@ -86,7 +86,7 @@ function expectZosmfResponseFailed(response: any, error: ImperativeError, msg: s describe("ListInstanceInfo listInstanceCommon", () => { it("should succeed with all correctly provided parameters", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); diff --git a/packages/provisioning/__tests__/__unit__/ListInstanceVariables.unit.test.ts b/packages/provisioning/__tests__/__unit__/ListInstanceVariables.unit.test.ts index 9774743aa2..6747dd445d 100644 --- a/packages/provisioning/__tests__/__unit__/ListInstanceVariables.unit.test.ts +++ b/packages/provisioning/__tests__/__unit__/ListInstanceVariables.unit.test.ts @@ -64,7 +64,7 @@ describe("ListInstanceVariables getResourcesQuery", () => { describe("ListInstanceVariables listVariablesCommon", () => { it("should succeed and return list of variables", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); diff --git a/packages/provisioning/__tests__/__unit__/ListRegistryInstances.unit.test.ts b/packages/provisioning/__tests__/__unit__/ListRegistryInstances.unit.test.ts index 534f7eaedf..f23ea7af8b 100644 --- a/packages/provisioning/__tests__/__unit__/ListRegistryInstances.unit.test.ts +++ b/packages/provisioning/__tests__/__unit__/ListRegistryInstances.unit.test.ts @@ -147,7 +147,7 @@ describe("ListRegistryInstances getResourcesQuery", () => { describe("ListRegistryInstances listRegistryCommon", () => { it("should succeed and return list of provisioned instances", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); @@ -172,7 +172,7 @@ describe("ListRegistryInstances listRegistryCommon", () => { }); it("should succeed and return list of instances filtered by DB2 type", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE_DB2_TYPE); @@ -240,7 +240,7 @@ describe("ListRegistryInstances listRegistryCommon", () => { describe("ListRegistryInstances listFilteredRegistry", () => { it("should succeed and return list of instances filtered by 'type'", async () => { - (ListRegistryInstances.listRegistryCommon as any) = jest.fn((): Promise => { + (ListRegistryInstances.listRegistryCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE_DB2_TYPE); @@ -267,7 +267,7 @@ describe("ListRegistryInstances listFilteredRegistry", () => { }); it("should succeed and return list of instances filtered by 'external-name'", async () => { - (ListRegistryInstances.listRegistryCommon as any) = jest.fn((): Promise => { + (ListRegistryInstances.listRegistryCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE_DB2_TYPE); @@ -294,7 +294,7 @@ describe("ListRegistryInstances listFilteredRegistry", () => { }); it("should succeed and return list of templates filtered by 'type' and 'external-name'", async () => { - (ListRegistryInstances.listRegistryCommon as any) = jest.fn((): Promise => { + (ListRegistryInstances.listRegistryCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE_CICS_TYPE); diff --git a/packages/provisioning/__tests__/__unit__/ListTemplateInfo.unit.test.ts b/packages/provisioning/__tests__/__unit__/ListTemplateInfo.unit.test.ts index 684a503a58..a26e7bf533 100644 --- a/packages/provisioning/__tests__/__unit__/ListTemplateInfo.unit.test.ts +++ b/packages/provisioning/__tests__/__unit__/ListTemplateInfo.unit.test.ts @@ -100,7 +100,7 @@ describe("ListTemplateInfo getResourcesQuery", () => { describe("ListTemplateInfo listTemplateCommon", () => { it("should succeed with all correctly provided parameters", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE_NO_PROMPT_VARS); diff --git a/packages/provisioning/__tests__/__unit__/PerformAction.unit.test.ts b/packages/provisioning/__tests__/__unit__/PerformAction.unit.test.ts index 13203de26f..0437057c72 100644 --- a/packages/provisioning/__tests__/__unit__/PerformAction.unit.test.ts +++ b/packages/provisioning/__tests__/__unit__/PerformAction.unit.test.ts @@ -62,7 +62,7 @@ describe("PerformAction getResourcesQuery", () => { describe("PerformAction doProvisioningActionCommon", () => { it("should succeed with all correct parameters", async () => { - (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); diff --git a/packages/provisioning/__tests__/__unit__/ProvisionPublishedTemplate.unit.test.ts b/packages/provisioning/__tests__/__unit__/ProvisionPublishedTemplate.unit.test.ts index c73fb79bc5..4161c9f7ca 100644 --- a/packages/provisioning/__tests__/__unit__/ProvisionPublishedTemplate.unit.test.ts +++ b/packages/provisioning/__tests__/__unit__/ProvisionPublishedTemplate.unit.test.ts @@ -75,7 +75,7 @@ function expectZosmfResponseFailed(response: IProvisionTemplateResponse, error: describe("ProvisionPublishedTemplate", () => { it("provisionTemplate should succeed without passed optional parameters", async () => { - (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -97,7 +97,7 @@ describe("ProvisionPublishedTemplate", () => { }); it("provisionTemplate should succeed with passed optional parameters", async () => { - (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -185,7 +185,7 @@ describe("ProvisionPublishedTemplate", () => { }); it("provisionTemplateCommon should succeed with all correct parameters", async () => { - (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); diff --git a/packages/workflows/__tests__/__unit__/Archive.unit.test.ts b/packages/workflows/__tests__/__unit__/Archive.unit.test.ts index 9717de9aab..4cceacfb03 100644 --- a/packages/workflows/__tests__/__unit__/Archive.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/Archive.unit.test.ts @@ -26,7 +26,7 @@ const workflowKeyConst: string = "0123-456789-abc-def"; describe("Archive workflow unit tests - successful scenarios", () => { it("Successful archive", async ()=>{ - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise((resolve)=>{ Imperative.console.info("Using mocked function"); process.nextTick(()=>{ @@ -119,7 +119,7 @@ describe("Missing workflow key", ()=> { describe("Missing z/OSMF version", ()=>{ it("Missing z/OSMF REST API version", async ()=>{ - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise((resolve)=>{ Imperative.console.info("Using mocked function"); process.nextTick(()=>{ @@ -148,7 +148,7 @@ describe("Errors caused by the user interaction", ()=>{ it("400 Bad Request", async ()=>{ const errorCodeConst = "400"; const msgConst = "Bad Request"; - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise(()=>{ Imperative.console.info("Using mocked function"); const error = new ImperativeError({ @@ -170,7 +170,7 @@ describe("Errors caused by the user interaction", ()=>{ it("403 Forbidden", async ()=>{ const errorCodeConst = "403"; const msgConst = "Forbidden"; - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise(()=>{ Imperative.console.info("Using mocked function"); const error = new ImperativeError({ @@ -192,7 +192,7 @@ describe("Errors caused by the user interaction", ()=>{ it("404 Not Found", async ()=>{ const errorCodeConst = "404"; const msgConst = "Not Found"; - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise(()=>{ Imperative.console.info("Using mocked function"); const error = new ImperativeError({ @@ -214,7 +214,7 @@ describe("Errors caused by the user interaction", ()=>{ it("409 Request Conflict", async ()=>{ const errorCodeConst = "409"; const msgConst = "Request Conflict"; - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise(()=>{ Imperative.console.info("Using mocked function"); const error = new ImperativeError({ @@ -236,7 +236,7 @@ describe("Errors caused by the user interaction", ()=>{ it("401 Unauthorized", async ()=>{ const errorCodeConst = "401"; const msgConst = "Unauthorized"; - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise(()=>{ Imperative.console.info("Using mocked function"); const error = new ImperativeError({ diff --git a/packages/workflows/__tests__/__unit__/ArchivedDelete.unit.test.ts b/packages/workflows/__tests__/__unit__/ArchivedDelete.unit.test.ts index 707f2d37c2..e59bb74d8c 100644 --- a/packages/workflows/__tests__/__unit__/ArchivedDelete.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/ArchivedDelete.unit.test.ts @@ -45,7 +45,7 @@ describe("Delete archived workflow", () => { describe("Successful scenarios", () => { it("Successful call returns 204 - No Content.", async () => { - (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { + (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { return ""; }); @@ -65,7 +65,7 @@ describe("Delete archived workflow", () => { }); it("Successful even with zOSMF version undefined (because of default value).", async () => { - (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { + (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { return ""; }); diff --git a/packages/workflows/__tests__/__unit__/Cancel.unit.test.ts b/packages/workflows/__tests__/__unit__/Cancel.unit.test.ts index aab50199b9..f1cbb8329a 100644 --- a/packages/workflows/__tests__/__unit__/Cancel.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/Cancel.unit.test.ts @@ -45,7 +45,7 @@ describe("Cancel workflow", () => { describe("Successful scenarios", () => { it("Successful call returns 204 - No Content.", async () => { - (ZosmfRestClient.putExpectString as any) = jest.fn(() => { + (ZosmfRestClient.putExpectString as any) = jest.fn(() => { return ""; }); @@ -66,7 +66,7 @@ describe("Cancel workflow", () => { }); it("Successful even with zOSMF version undefined (because of default value).", async () => { - (ZosmfRestClient.putExpectString as any) = jest.fn(() => { + (ZosmfRestClient.putExpectString as any) = jest.fn(() => { return ""; }); diff --git a/packages/workflows/__tests__/__unit__/Create.unit.test.ts b/packages/workflows/__tests__/__unit__/Create.unit.test.ts index ff9b4fac29..bf7aae6fdd 100644 --- a/packages/workflows/__tests__/__unit__/Create.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/Create.unit.test.ts @@ -103,7 +103,7 @@ describe("Create workflow", () => { describe("Successful scenarios", () => { it("Successful call with all parameters returns IRegisteredWorkflow response.", async () => { - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -129,7 +129,7 @@ describe("Create workflow", () => { it("Successful call without optional parameters returns IRegisteredWorkflow response.", async () => { - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -154,7 +154,7 @@ describe("Create workflow", () => { }); it("Successful call without optional parameters and variables are empty string returns IRegisteredWorkflow response.", async () => { - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -179,7 +179,7 @@ describe("Create workflow", () => { expect(response).toEqual(PRETEND_ZOSMF_RESPONSE); }); it("Should succeed even with zOSMF version undefined (because of default value).", async () => { - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -206,7 +206,7 @@ describe("Create workflow", () => { it("Successful call with short DSNAME.", async () => { PRETEND_INPUT_PARMS_NO_INPUT.workflowDefinitionFile = "A.A.C"; const definitionFile = PRETEND_INPUT_PARMS_NO_INPUT.workflowDefinitionFile; - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -232,7 +232,7 @@ describe("Create workflow", () => { it("Successful call with DSNAME including member.", async () => { PRETEND_INPUT_PARMS_NO_INPUT.workflowDefinitionFile = "DATA.SET(MEMBER)"; const definitionFile = PRETEND_INPUT_PARMS_NO_INPUT.workflowDefinitionFile; - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -258,7 +258,7 @@ describe("Create workflow", () => { it("Successful call with DSNAME starting with special character(allowed one).", async () => { PRETEND_INPUT_PARMS_NO_INPUT.workflowDefinitionFile = "#DATA.SET"; const definitionFile = PRETEND_INPUT_PARMS_NO_INPUT.workflowDefinitionFile; - (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -434,24 +434,24 @@ describe("Create workflow", () => { describe("Create workflow from local file", () => { describe("Successful scenarios", () => { it("Should succeed even with zOSMF version undefined (because of default value).", async () => { - (Upload.fileToUSSFile as any) = jest.fn(() => { + (Upload.fileToUSSFile as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve("success"); }); }); }); - (CreateWorkflow.getTempFile as any) = jest.fn(() => { + (CreateWorkflow.getTempFile as any) = jest.fn(() => { return PRETEND_INPUT_PARMS.workflowDefinitionFile; }); - (CreateWorkflow.createWorkflow as any) = jest.fn(() => { + (CreateWorkflow.createWorkflow as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); }); }); }); - (Delete.ussFile as any) = jest.fn(() => { + (Delete.ussFile as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve("success"); @@ -477,17 +477,17 @@ describe("Create workflow from local file", () => { expect((Delete.ussFile as any)).toHaveBeenCalledWith(PRETEND_SESSION, PRETEND_INPUT_PARMS.workflowDefinitionFile.slice(1)); }); it("Should succeed and keep files", async () => { - (Upload.fileToUSSFile as any) = jest.fn(() => { + (Upload.fileToUSSFile as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve("success"); }); }); }); - (CreateWorkflow.getTempFile as any) = jest.fn(() => { + (CreateWorkflow.getTempFile as any) = jest.fn(() => { return PRETEND_INPUT_PARMS.workflowDefinitionFile; }); - (CreateWorkflow.createWorkflow as any) = jest.fn(() => { + (CreateWorkflow.createWorkflow as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -651,14 +651,14 @@ describe("Create workflow from local file", () => { it("Throws an error if uss files were not uploaded successfully", async () => { let error: ImperativeError; let response: any; - (Upload.fileToUSSFile as any) = jest.fn(() => { + (Upload.fileToUSSFile as any) = jest.fn(() => { return new Promise((resolve, reject) => { process.nextTick(() => { reject(new ImperativeError({msg : "failed"})); }); }); }); - (CreateWorkflow.createWorkflow as any) = jest.fn(() => { + (CreateWorkflow.createWorkflow as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); diff --git a/packages/workflows/__tests__/__unit__/Definition.unit.test.ts b/packages/workflows/__tests__/__unit__/Definition.unit.test.ts index 55e12a17bc..af0e687912 100644 --- a/packages/workflows/__tests__/__unit__/Definition.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/Definition.unit.test.ts @@ -371,7 +371,7 @@ describe("Get workflow definition", () => { describe("Successful scenarios", () => { it("Successful call without optional parameters returns IWorkflowDefinition definition response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -396,7 +396,7 @@ describe("Get workflow definition", () => { it("Successful call with all optional parameters returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE_WITH_STEPSANDVARIABLES); @@ -422,7 +422,7 @@ describe("Get workflow definition", () => { it("Successful call with optional steps returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE_WITH_STEPS); @@ -448,7 +448,7 @@ describe("Get workflow definition", () => { it("Successful call with optional variables returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE_WITH_VARIABLES); @@ -474,7 +474,7 @@ describe("Get workflow definition", () => { it("Successful call with undefined zosmf version returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -499,7 +499,7 @@ describe("Get workflow definition", () => { it("Successful call without optional parameters - both undefined returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -524,7 +524,7 @@ describe("Get workflow definition", () => { it("Successful call without optional parameters steps - set null IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -549,7 +549,7 @@ describe("Get workflow definition", () => { it("Successful call without optional parameters variables - set null IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -574,7 +574,7 @@ describe("Get workflow definition", () => { it("Successful call without both optional parameters variables - both set null IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); diff --git a/packages/workflows/__tests__/__unit__/Delete.unit.test.ts b/packages/workflows/__tests__/__unit__/Delete.unit.test.ts index 09eaf330f2..5ae8060789 100644 --- a/packages/workflows/__tests__/__unit__/Delete.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/Delete.unit.test.ts @@ -46,7 +46,7 @@ describe("Delete workflow", () => { describe("Successful scenarios", () => { it("Successful call returns 204 - No Content.", async () => { - (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { + (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { return ""; }); @@ -66,7 +66,7 @@ describe("Delete workflow", () => { }); it("Successful even with zOSMF version undefined (because of default value).", async () => { - (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { + (ZosmfRestClient.deleteExpectString as any) = jest.fn(() => { return ""; }); diff --git a/packages/workflows/__tests__/__unit__/ListArchivedWorkflows.unit.test.ts b/packages/workflows/__tests__/__unit__/ListArchivedWorkflows.unit.test.ts index b114ad0ae2..7f6bfe04fb 100644 --- a/packages/workflows/__tests__/__unit__/ListArchivedWorkflows.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/ListArchivedWorkflows.unit.test.ts @@ -56,7 +56,7 @@ describe("List archived workflows", () => { // List all archived workflows - without any optional parameters it("Successful call without any optional parameters.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); diff --git a/packages/workflows/__tests__/__unit__/ListWorkflows.unit.test.ts b/packages/workflows/__tests__/__unit__/ListWorkflows.unit.test.ts index 50b4109a30..8d038bee0c 100644 --- a/packages/workflows/__tests__/__unit__/ListWorkflows.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/ListWorkflows.unit.test.ts @@ -96,7 +96,7 @@ describe("List workflows", () => { // List workflow that match all optional parameters it("Successful call with all optional parameters.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -121,7 +121,7 @@ describe("List workflows", () => { // List all workflows - without any optional parameters it("Successful call without any optional parameters.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -175,7 +175,7 @@ describe("Get workflow key by name", () => { describe("Success scenarios", () => { it("Returns wf key if only one wf with requested name was found", async () => { const apiResponse = {workflows: [PRETEND_ZOSMF_RESPONSE]}; - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(apiResponse); @@ -196,7 +196,7 @@ describe("Get workflow key by name", () => { }); it("Returns null if no workflow with requested name was found", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve({workflows: []}); @@ -242,7 +242,7 @@ describe("Get workflow key by name", () => { expectZosmfResponseFailed(response, error, noWorkflowName.message); }); it("Throws an error if multiple wf were found.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE_MULTIPLE_WF); diff --git a/packages/workflows/__tests__/__unit__/Properties.unit.test.ts b/packages/workflows/__tests__/__unit__/Properties.unit.test.ts index 1717c86d84..9002dcee36 100644 --- a/packages/workflows/__tests__/__unit__/Properties.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/Properties.unit.test.ts @@ -639,7 +639,7 @@ describe("Get workflow properties", () => { describe("Successful scenarios", () => { it("Successful call without optional parameters returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -664,7 +664,7 @@ describe("Get workflow properties", () => { it("Successful call with all optional parameters returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE_WITH_STEPSANDVARIABLES); @@ -690,7 +690,7 @@ describe("Get workflow properties", () => { it("Successful call with optional steps returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE_WITH_STEPS); @@ -716,7 +716,7 @@ describe("Get workflow properties", () => { it("Successful call with optional variables returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE_WITH_VARIABLES); @@ -742,7 +742,7 @@ describe("Get workflow properties", () => { it("Successful call with undefined zosmf version returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -767,7 +767,7 @@ describe("Get workflow properties", () => { it("Successful call without optional parameters - both undefined returns IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -792,7 +792,7 @@ describe("Get workflow properties", () => { it("Successful call without optional parameters steps - set null IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -817,7 +817,7 @@ describe("Get workflow properties", () => { it("Successful call without optional parameters variables - set null IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -842,7 +842,7 @@ describe("Get workflow properties", () => { it("Successful call without both optional parameters variables - both set null IRegisteredWorkflow properties response.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn(() => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); diff --git a/packages/workflows/__tests__/__unit__/Start.unit.test.ts b/packages/workflows/__tests__/__unit__/Start.unit.test.ts index 00fa1d95a8..54d4a1f376 100644 --- a/packages/workflows/__tests__/__unit__/Start.unit.test.ts +++ b/packages/workflows/__tests__/__unit__/Start.unit.test.ts @@ -50,7 +50,7 @@ describe("Start workflow", () => { it("Successful call returns 201 - no message. Test just with workflow key.", async () => { - (ZosmfRestClient.putExpectString as any) = jest.fn(() => { + (ZosmfRestClient.putExpectString as any) = jest.fn(() => { return ""; }); @@ -71,7 +71,7 @@ describe("Start workflow", () => { }); it("Should succeed even with zOSMF version undefined(because of default value).", async () => { - (ZosmfRestClient.putExpectString as any) = jest.fn(() => { + (ZosmfRestClient.putExpectString as any) = jest.fn(() => { return ""; }); @@ -92,7 +92,7 @@ describe("Start workflow", () => { }); it("Should succeed with all optional variables.", async () => { - (ZosmfRestClient.putExpectString as any) = jest.fn(() => { + (ZosmfRestClient.putExpectString as any) = jest.fn(() => { return ""; }); diff --git a/packages/zosconsole/__tests__/__unit__/CollectCommand.unit.test.ts b/packages/zosconsole/__tests__/__unit__/CollectCommand.unit.test.ts index 161a88d8c9..dce4e21e62 100644 --- a/packages/zosconsole/__tests__/__unit__/CollectCommand.unit.test.ts +++ b/packages/zosconsole/__tests__/__unit__/CollectCommand.unit.test.ts @@ -100,7 +100,7 @@ describe("CollectCommand collectCommon", () => { * Verify that ZosmfRestClient.getExpectJSON method has been called with proper parameters */ it("should get response from custom console.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_RESPONSE); @@ -128,7 +128,7 @@ describe("CollectCommand collectCommon", () => { * Command should fail with incorrect parameters and */ it("should fail if session is not provided.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_RESPONSE); @@ -177,7 +177,7 @@ describe("CollectCommand collectCommon", () => { }); it("should handle Imperative error.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { throw new ImperativeError({msg: "Collect error message"}, {suppressReport: false, tag: "some tag"}); }); @@ -196,7 +196,7 @@ describe("CollectCommand collectCommon", () => { describe("CollectCommand collectDefConsoleCommon", () => { it("should get response from default console.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_RESPONSE); @@ -223,7 +223,7 @@ describe("CollectCommand collectDefConsoleCommon", () => { describe("CollectCommand collect", () => { it("should get response from custom console.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_RESPONSE1); @@ -249,7 +249,7 @@ describe("CollectCommand collect", () => { }); it("should get response (one chunk of data provided as a response).", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_RESPONSE1); @@ -275,7 +275,7 @@ describe("CollectCommand collect", () => { }); it("should get response (two chunks of data with empty responses provided as a response).", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_RESPONSE1); @@ -306,7 +306,7 @@ describe("CollectCommand collect", () => { }); it("should handle Imperative error.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { throw new ImperativeError({msg: "Issue error message"}, {suppressReport: false, tag: "some tag"}); }) .mockReturnValueOnce(FOLLOW_UP_RESPONSE1); @@ -331,7 +331,7 @@ describe("CollectCommand collect", () => { }); it("with non empty console response should collect all data.", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((reject) => { process.nextTick(() => { reject(FOLLOW_UP_RESPONSE1); diff --git a/packages/zosconsole/__tests__/__unit__/IssueCommand.unit.test.ts b/packages/zosconsole/__tests__/__unit__/IssueCommand.unit.test.ts index 2bffceb16c..69c57db3df 100644 --- a/packages/zosconsole/__tests__/__unit__/IssueCommand.unit.test.ts +++ b/packages/zosconsole/__tests__/__unit__/IssueCommand.unit.test.ts @@ -177,7 +177,7 @@ describe("IssueCommand buildZosmfConsoleApiParameters", () => { describe("IssueCommand issueCommon", () => { it("with correct parameters should succeed.", async () => { - (ZosmfRestClient.putExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_RESPONSE); @@ -241,7 +241,7 @@ describe("IssueCommand issueCommon", () => { }); it("should handle Imperative error.", async () => { - (ZosmfRestClient.putExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn((): Promise => { throw new ImperativeError({msg: "Issue error message"}, {suppressReport: false, tag: "some tag"}); }); @@ -262,7 +262,7 @@ describe("IssueCommand issueCommon", () => { describe("IssueCommand issueDefConsoleCommon", () => { it("with correct parameters should succeed.", async () => { - (IssueCommand.issueCommon as any) = jest.fn((): Promise => { + (IssueCommand.issueCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_RESPONSE); @@ -304,7 +304,7 @@ describe("IssueCommand issue", () => { it("with correct parameters should succeed.", async () => { - (IssueCommand.issueCommon as any) = jest.fn((): Promise => { + (IssueCommand.issueCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_RESPONSE); @@ -329,7 +329,7 @@ describe("IssueCommand issue", () => { }); it("with default console name should succeed.", async () => { - (IssueCommand.issueCommon as any) = jest.fn((): Promise => { + (IssueCommand.issueCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_RESPONSE); @@ -352,7 +352,7 @@ describe("IssueCommand issue", () => { }); it("with custom console name should succeed.", async () => { - (IssueCommand.issueCommon as any) = jest.fn((): Promise => { + (IssueCommand.issueCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_RESPONSE); @@ -375,7 +375,7 @@ describe("IssueCommand issue", () => { }); it("with keyword should succeed.", async () => { - (IssueCommand.issueCommon as any) = jest.fn((): Promise => { + (IssueCommand.issueCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_KEYWORD_RESPONSE); @@ -398,7 +398,7 @@ describe("IssueCommand issue", () => { }); it("should handle Imperative error.", async () => { - (IssueCommand.issueCommon as any) = jest.fn((): Promise => { + (IssueCommand.issueCommon as any) = jest.fn((): Promise => { throw new ImperativeError({msg: "Test error message"}, {suppressReport: false, tag: "some tag"}); }); @@ -420,7 +420,7 @@ describe("IssueCommand issue", () => { describe("IssueCommand issueSimple", () => { it("with correct parameters should succeed.", async () => { - (IssueCommand.issueCommon as any) = jest.fn((): Promise => { + (IssueCommand.issueCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(CMD_RESPONSE); @@ -448,7 +448,7 @@ describe("IssueCommand issueSimple", () => { describe("IssueCommand issueAndCollect", () => { it("should succeed.", async () => { - (IssueCommand.issue as any) = jest.fn((): Promise => { + (IssueCommand.issue as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_CONSOLE_RESPONSE); @@ -456,7 +456,7 @@ describe("IssueCommand issueAndCollect", () => { }); }); - (CollectCommand.collect as any) = jest.fn((): Promise => { + (CollectCommand.collect as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_CONSOLE_RESPONSE); @@ -484,7 +484,7 @@ describe("IssueCommand issueAndCollect", () => { }); it("should not call collect method if response key from issue is empty.", async () => { - (IssueCommand.issue as any) = jest.fn((): Promise => { + (IssueCommand.issue as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_CONSOLE_NO_KEY_RESPONSE); @@ -492,7 +492,7 @@ describe("IssueCommand issueAndCollect", () => { }); }); - (CollectCommand.collect as any) = jest.fn((): Promise => { + (CollectCommand.collect as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_CONSOLE_RESPONSE); @@ -516,7 +516,7 @@ describe("IssueCommand issueAndCollect", () => { }); it("should not call collect if keyword was detected after issue.", async () => { - (IssueCommand.issue as any) = jest.fn((): Promise => { + (IssueCommand.issue as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_CONSOLE_SOLICITED_RESPONSE); @@ -524,7 +524,7 @@ describe("IssueCommand issueAndCollect", () => { }); }); - (CollectCommand.collect as any) = jest.fn((): Promise => { + (CollectCommand.collect as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_CONSOLE_RESPONSE); @@ -548,7 +548,7 @@ describe("IssueCommand issueAndCollect", () => { }); it("should not call collect if issue call returns Imperative error.", async () => { - (IssueCommand.issue as any) = jest.fn((): Promise => { + (IssueCommand.issue as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(IMPERATIVE_ERROR_RESPONSE); @@ -556,7 +556,7 @@ describe("IssueCommand issueAndCollect", () => { }); }); - (CollectCommand.collect as any) = jest.fn((): Promise => { + (CollectCommand.collect as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(FOLLOW_UP_CONSOLE_RESPONSE); diff --git a/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts b/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts index a190a6c7ec..145ef0defa 100644 --- a/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts +++ b/packages/zosfiles/__tests__/__unit__/methods/upload/Upload.unit.test.ts @@ -26,7 +26,7 @@ import { Utilities } from "../../../../src/methods/utilities/Utilities"; import { ZosFilesUtils } from "../../../../src/utils/ZosFilesUtils"; import { stripNewLines } from "../../../../../../__tests__/__src__/TestUtils"; import { Create } from "../../../../src/methods/create"; -import { Tag, TransferMode, ZosFilesAttributes, ZosFilesMessages } from "../../../../src"; +import { Tag, TransferMode, ZosFilesMessages } from "../../../../src"; import { CLIENT_PROPERTY } from "../../../../src/doc/types/ZosmfRestClientProperties"; import { Readable } from "stream"; @@ -43,12 +43,12 @@ describe("z/OS Files - Upload", () => { type: "basic" }); - let response: IZosFilesResponse; + let response: IZosFilesResponse | any; let error: any; describe("fileToDataset", () => { const dataSetSpy = jest.spyOn(Upload as any, "pathToDataSet"); - const lsStatSpy = jest.spyOn(fs, "lstat"); + const lsStatSpy: any = jest.spyOn(fs, "lstat"); beforeEach(() => { response = undefined; @@ -59,7 +59,7 @@ describe("z/OS Files - Upload", () => { it("should throw error if file path is not specified", async () => { try { - response = await Upload.fileToDataset(dummySession, undefined, dsName); + response = await Upload.fileToDataset(dummySession, undefined as any, dsName); } catch (err) { error = err; } @@ -71,7 +71,7 @@ describe("z/OS Files - Upload", () => { it("should throw error if data set name is not specified", async () => { const testPath = "test.path"; try { - response = await Upload.fileToDataset(dummySession, testPath, undefined); + response = await Upload.fileToDataset(dummySession, testPath, undefined as any); } catch (err) { error = err; } @@ -166,7 +166,7 @@ describe("z/OS Files - Upload", () => { describe("dirToPds", () => { const isDirSpy = jest.spyOn(IO, "isDir"); const dataSetSpy = jest.spyOn(Upload as any, "pathToDataSet"); - const lsStatSpy = jest.spyOn(fs, "lstat"); + const lsStatSpy: any = jest.spyOn(fs, "lstat"); beforeEach(() => { response = undefined; @@ -177,7 +177,7 @@ describe("z/OS Files - Upload", () => { it("should throw error if directory path is not specified", async () => { try { - response = await Upload.dirToPds(dummySession, undefined, dsName); + response = await Upload.dirToPds(dummySession, undefined as any, dsName); } catch (err) { error = err; } @@ -190,7 +190,7 @@ describe("z/OS Files - Upload", () => { const testDir = "path/to/a/file"; const dsname = "TEST.DSN"; try { - response = await Upload.dirToPds(dummySession, testDir, undefined); + response = await Upload.dirToPds(dummySession, testDir, undefined as any); } catch (err) { error = err; } @@ -320,21 +320,21 @@ describe("z/OS Files - Upload", () => { describe("bufferToDataSet", () => { const zosmfExpectSpy = jest.spyOn(ZosmfRestClient, "putExpectString"); const zosmfPutFullSpy = jest.spyOn(ZosmfRestClient, "putExpectFullResponse"); - const fakeResponseWithEtag = {data: dsName, response:{headers:{etag: etagValue}}}; + const fakeResponseWithEtag: any = {data: dsName, response:{headers:{etag: etagValue}}}; beforeEach(() => { response = undefined; error = undefined; zosmfExpectSpy.mockClear(); - zosmfExpectSpy.mockImplementation(() => null); + zosmfExpectSpy.mockImplementation(() => null as any); zosmfPutFullSpy.mockClear(); - zosmfPutFullSpy.mockImplementation(() => null); + zosmfPutFullSpy.mockImplementation(() => null as any); }); it("should throw error if data set name is not specified", async () => { try { - response = await Upload.bufferToDataSet(dummySession, Buffer.from("testing"), undefined); + response = await Upload.bufferToDataSet(dummySession, Buffer.from("testing"), undefined as any); } catch (err) { error = err; } @@ -652,7 +652,7 @@ describe("z/OS Files - Upload", () => { }); }); describe("streamToDataSet", () => { - const zosmfPutFullSpy = jest.spyOn(ZosmfRestClient, "putExpectFullResponse"); + const zosmfPutFullSpy: any = jest.spyOn(ZosmfRestClient, "putExpectFullResponse"); const fakeResponseWithEtag = {data: dsName, response:{headers:{etag: etagValue}}}; const inputStream = new Readable(); inputStream.push("testing"); @@ -663,12 +663,12 @@ describe("z/OS Files - Upload", () => { error = undefined; zosmfPutFullSpy.mockClear(); - zosmfPutFullSpy.mockImplementation(() => null); + zosmfPutFullSpy.mockImplementation(() => null as any); }); it("should throw error if data set name is not specified", async () => { try { - response = await Upload.streamToDataSet(dummySession, inputStream, undefined); + response = await Upload.streamToDataSet(dummySession, inputStream, undefined as any); } catch (err) { error = err; } @@ -1162,7 +1162,7 @@ describe("z/OS Files - Upload", () => { it("should throw error when inputPath is not defined", async () => { try { - response = await Upload.pathToDataSet(dummySession, undefined, dsName); + response = await Upload.pathToDataSet(dummySession, undefined as any, dsName); } catch (err) { error = err; } @@ -1172,7 +1172,7 @@ describe("z/OS Files - Upload", () => { }); it("should throw error when dataSet name is not defined", async () => { try { - response = await Upload.pathToDataSet(dummySession, "dummyPath", undefined); + response = await Upload.pathToDataSet(dummySession, "dummyPath", undefined as any); } catch (err) { error = err; } @@ -1227,7 +1227,7 @@ describe("z/OS Files - Upload", () => { writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); isDirSpy.mockReturnValueOnce(true); try { @@ -1258,11 +1258,11 @@ describe("z/OS Files - Upload", () => { writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); try { response = await Upload.pathToDataSet(dummySession, "dummyPath", dsName); @@ -1292,11 +1292,11 @@ describe("z/OS Files - Upload", () => { writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); try { response = await Upload.pathToDataSet(dummySession, "dummyPath", dsName); @@ -1328,11 +1328,11 @@ describe("z/OS Files - Upload", () => { writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); try { response = await Upload.pathToDataSet(dummySession, "dummyPath", dsName, {responseTimeout:5}); @@ -1364,7 +1364,7 @@ describe("z/OS Files - Upload", () => { writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); try { response = await Upload.pathToDataSet(dummySession, "dummyPath", dsName); @@ -1398,7 +1398,7 @@ describe("z/OS Files - Upload", () => { apiResponse: { etag: etagValue } - }); + } as any); const uploadOptions: IUploadOptions = { returnEtag: true }; @@ -1434,7 +1434,7 @@ describe("z/OS Files - Upload", () => { writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); isDirSpy.mockReturnValueOnce(false); try { @@ -1466,7 +1466,7 @@ describe("z/OS Files - Upload", () => { writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); writeZosmfDatasetSpy.mockRejectedValueOnce(new ImperativeError({ msg: "dummy error" })); @@ -1501,7 +1501,7 @@ describe("z/OS Files - Upload", () => { writeZosmfDatasetSpy.mockResolvedValueOnce({ success: true, CommandResponse: "dummy" - }); + } as any); writeZosmfDatasetSpy.mockRejectedValueOnce(new ImperativeError({ msg: "dummy error" })); @@ -1525,15 +1525,15 @@ describe("z/OS Files - Upload", () => { const zosmfExpectSpy = jest.spyOn(ZosmfRestClient, "putExpectString"); let USSresponse: string; beforeEach(() => { - USSresponse = undefined; + USSresponse = undefined as any; error = undefined; zosmfExpectSpy.mockClear(); - zosmfExpectSpy.mockImplementation(() => null); + zosmfExpectSpy.mockImplementation(() => null as any); }); it("should throw an error if USS file name is not specified", async () => { try { - USSresponse = await Upload.bufferToUSSFile(dummySession, undefined, Buffer.from("testing")); + USSresponse = await Upload.bufferToUSSFile(dummySession, undefined as any, Buffer.from("testing")); } catch (err) { error = err; } @@ -1661,8 +1661,8 @@ describe("z/OS Files - Upload", () => { }); describe("streamToUssFile", () => { - let USSresponse: IZosFilesResponse; - const zosmfExpectFullSpy = jest.spyOn(ZosmfRestClient, "putExpectFullResponse"); + let USSresponse: IZosFilesResponse | any; + const zosmfExpectFullSpy: any = jest.spyOn(ZosmfRestClient, "putExpectFullResponse"); const fakeResponseWithEtag = {data: dsName, response:{headers:{etag: etagValue}}}; const inputStream = new Readable(); inputStream.push("testing"); @@ -1673,7 +1673,7 @@ describe("z/OS Files - Upload", () => { error = undefined; zosmfExpectFullSpy.mockClear(); - zosmfExpectFullSpy.mockImplementation(() => null); + zosmfExpectFullSpy.mockImplementation(() => null as any); }); afterAll(() => { @@ -1682,7 +1682,7 @@ describe("z/OS Files - Upload", () => { it("should throw an error if USS file name is not specified", async () => { try { - USSresponse = await Upload.streamToUssFile(dummySession, undefined, inputStream); + USSresponse = await Upload.streamToUssFile(dummySession, undefined as any, inputStream); } catch (err) { error = err; } @@ -1837,10 +1837,10 @@ describe("z/OS Files - Upload", () => { }); describe("fileToUssFile", () => { - let USSresponse: IZosFilesResponse; + let USSresponse: IZosFilesResponse | any; const createReadStreamSpy = jest.spyOn(IO, "createReadStream"); const streamToUssFileSpy = jest.spyOn(Upload, "streamToUssFile"); - const lsStatSpy = jest.spyOn(fs, "lstat"); + const lsStatSpy: any = jest.spyOn(fs, "lstat"); const inputFile = "/path/to/file1.txt"; beforeEach(() => { @@ -1848,10 +1848,10 @@ describe("z/OS Files - Upload", () => { error = undefined; createReadStreamSpy.mockReset(); - createReadStreamSpy.mockImplementation(() => null); + createReadStreamSpy.mockImplementation(() => null as any); streamToUssFileSpy.mockReset(); - streamToUssFileSpy.mockImplementation(() => null); + streamToUssFileSpy.mockImplementation(() => null as any); lsStatSpy.mockClear(); lsStatSpy.mockImplementation((somePath, callback) => { @@ -1861,7 +1861,7 @@ describe("z/OS Files - Upload", () => { it("should throw an error if local file name is not specified", async () => { try { - USSresponse = await Upload.fileToUssFile(dummySession, undefined, "file"); + USSresponse = await Upload.fileToUssFile(dummySession, undefined as any, "file"); } catch (err) { error = err; } @@ -1872,7 +1872,7 @@ describe("z/OS Files - Upload", () => { }); it("should throw an error if USS file name is not specified", async () => { try { - USSresponse = await Upload.fileToUssFile(dummySession, inputFile, undefined); + USSresponse = await Upload.fileToUssFile(dummySession, inputFile, undefined as any); } catch (err) { error = err; } @@ -1948,7 +1948,7 @@ describe("z/OS Files - Upload", () => { expect(streamToUssFileSpy).toHaveBeenCalledWith(dummySession, "file", null, {responseTimeout: 5}); }); it("return with proper response when upload USS file including Etag", async () => { - const streamResponse: IZosFilesResponse = { + const streamResponse: IZosFilesResponse | any = { success: true, commandResponse: undefined, apiResponse: {etag: etagValue}}; @@ -1974,7 +1974,7 @@ describe("z/OS Files - Upload", () => { callback(null, {isFile: () => false}); }); try { - USSresponse = await Upload.fileToUssFile(dummySession, undefined, "file"); + USSresponse = await Upload.fileToUssFile(dummySession, undefined as any, "file"); } catch (err) { error = err; } @@ -1986,7 +1986,7 @@ describe("z/OS Files - Upload", () => { }); }); describe("dirToUSSDirRecursive", () => { - let USSresponse: IZosFilesResponse; + let USSresponse: IZosFilesResponse | any; const isDirSpy = jest.spyOn(IO, "isDir"); const isDirectoryExistsSpy = jest.spyOn(Upload, "isDirectoryExist"); const getFileListFromPathSpy = jest.spyOn(ZosFilesUtils, "getFileListFromPath"); @@ -1999,7 +1999,7 @@ describe("z/OS Files - Upload", () => { const pathNormalizeSpy = jest.spyOn(path, "normalize"); const filterDirectoriesSpy = jest.spyOn(Array.prototype, "filter"); const promiseSpy = jest.spyOn(Promise, "all"); - const testReturn = {}; + const testReturn: any = {}; const testPath = "test/path"; beforeEach(() => { @@ -2016,8 +2016,8 @@ describe("z/OS Files - Upload", () => { zosmfExpectSpy.mockClear(); zosmfExpectFullSpy.mockClear(); filterDirectoriesSpy.mockClear(); - zosmfExpectSpy.mockImplementation(() => null); - zosmfExpectFullSpy.mockImplementation(() => null); + zosmfExpectSpy.mockImplementation(() => null as any); + zosmfExpectFullSpy.mockImplementation(() => null as any); }); afterAll(() => { @@ -2026,13 +2026,14 @@ describe("z/OS Files - Upload", () => { it("should upload recursively if option is specified", async () => { isDirSpy.mockReturnValue(true); - isDirectoryExistsSpy.mockReturnValueOnce(false).mockReturnValueOnce(true); - createUssDirSpy.mockReturnValueOnce({}).mockReturnValueOnce({}); - getFileListWithFsSpy.mockReturnValueOnce(["test", "file1.txt", "file2.txt"]).mockReturnValueOnce(["test", "file1.txt", "file2.txt"]) + isDirectoryExistsSpy.mockResolvedValueOnce(false).mockResolvedValueOnce(true); + createUssDirSpy.mockResolvedValueOnce({} as any).mockResolvedValueOnce({} as any); + getFileListWithFsSpy.mockReturnValueOnce(["test", "file1.txt", "file2.txt"] as any) + .mockReturnValueOnce(["test", "file1.txt", "file2.txt"] as any) .mockReturnValueOnce([]); filterDirectoriesSpy.mockReturnValueOnce(["test"]).mockReturnValueOnce(["test"]); getFileListFromPathSpy.mockReturnValueOnce(["file1.txt", "file2.txt"]).mockReturnValueOnce([]); - fileToUssFileSpy.mockReturnValue({}); + fileToUssFileSpy.mockReturnValue({} as any); try { USSresponse = await Upload.dirToUSSDirRecursive(dummySession, testPath, dsName); } catch (err) { @@ -2047,13 +2048,14 @@ describe("z/OS Files - Upload", () => { it("should upload recursively if option is specified and work with responseTimeout", async () => { isDirSpy.mockReturnValue(true); - isDirectoryExistsSpy.mockReturnValueOnce(false).mockReturnValueOnce(true); - createUssDirSpy.mockReturnValueOnce({}).mockReturnValueOnce({}); - getFileListWithFsSpy.mockReturnValueOnce(["test", "file1.txt", "file2.txt"]).mockReturnValueOnce(["test", "file1.txt", "file2.txt"]) + isDirectoryExistsSpy.mockResolvedValueOnce(false).mockResolvedValueOnce(true); + createUssDirSpy.mockReturnValueOnce({} as any).mockReturnValueOnce({} as any); + getFileListWithFsSpy.mockReturnValueOnce(["test", "file1.txt", "file2.txt"] as any) + .mockReturnValueOnce(["test", "file1.txt", "file2.txt"] as any) .mockReturnValueOnce([]); filterDirectoriesSpy.mockReturnValueOnce(["test"]).mockReturnValueOnce(["test"]); getFileListFromPathSpy.mockReturnValueOnce(["file1.txt", "file2.txt"]).mockReturnValueOnce([]); - fileToUssFileSpy.mockReturnValue({}); + fileToUssFileSpy.mockReturnValue({} as any); try { USSresponse = await Upload.dirToUSSDirRecursive(dummySession, testPath, dsName, {responseTimeout: 5}); } catch (err) { @@ -2068,7 +2070,7 @@ describe("z/OS Files - Upload", () => { it("should throw an error if local directory is not specified", async () => { try { - USSresponse = await Upload.dirToUSSDirRecursive(dummySession, undefined, dsName); + USSresponse = await Upload.dirToUSSDirRecursive(dummySession, undefined as any, dsName); } catch (err) { error = err; } @@ -2106,7 +2108,7 @@ describe("z/OS Files - Upload", () => { it("should throw an error if USS directory is not specified", async () => { try { - USSresponse = await Upload.dirToUSSDirRecursive(dummySession, "some/path", undefined); + USSresponse = await Upload.dirToUSSDirRecursive(dummySession, "some/path", undefined as any); } catch (err) { error = err; } @@ -2130,13 +2132,13 @@ describe("z/OS Files - Upload", () => { it("should return with proper response", async () => { isDirSpy.mockReturnValueOnce(true); - isDirectoryExistsSpy.mockReturnValueOnce(true); - getFileListWithFsSpy.mockReturnValueOnce(["file1", "file2"]); + isDirectoryExistsSpy.mockResolvedValueOnce(true); + getFileListWithFsSpy.mockReturnValueOnce(["file1", "file2"] as any); filterDirectoriesSpy.mockReturnValueOnce([]); getFileListFromPathSpy.mockReturnValueOnce(["file1", "file2"]); fileToUssFileSpy.mockReturnValue(testReturn); fileToUssFileSpy.mockReturnValue(testReturn); - promiseSpy.mockReturnValueOnce({}); + promiseSpy.mockReturnValueOnce({} as any); try { USSresponse = await Upload.dirToUSSDirRecursive(dummySession, testPath, dsName); @@ -2151,7 +2153,7 @@ describe("z/OS Files - Upload", () => { }); describe("dirToUSSDir", () => { - let USSresponse: IZosFilesResponse; + let USSresponse: IZosFilesResponse | any; const isDirSpy = jest.spyOn(IO, "isDir"); const isDirectoryExistsSpy = jest.spyOn(Upload, "isDirectoryExist"); const getFileListFromPathSpy = jest.spyOn(ZosFilesUtils, "getFileListFromPath"); @@ -2164,7 +2166,7 @@ describe("z/OS Files - Upload", () => { const pathNormalizeSpy = jest.spyOn(path, "normalize"); const promiseSpy = jest.spyOn(Promise, "all"); const filterDirectoriesSpy = jest.spyOn(Array.prototype, "filter"); - const testReturn = {}; + const testReturn: any = {}; const testPath = "test/path"; beforeEach(() => { @@ -2181,8 +2183,8 @@ describe("z/OS Files - Upload", () => { zosmfExpectSpy.mockClear(); zosmfExpectFullSpy.mockClear(); filterDirectoriesSpy.mockClear(); - zosmfExpectSpy.mockImplementation(() => null); - zosmfExpectFullSpy.mockImplementation(() => null); + zosmfExpectSpy.mockImplementation(() => null as any); + zosmfExpectFullSpy.mockImplementation(() => null as any); }); afterAll(() => { @@ -2191,7 +2193,7 @@ describe("z/OS Files - Upload", () => { it("should throw an error if local directory is not specified", async () => { try { - USSresponse = await Upload.dirToUSSDir(dummySession, undefined, dsName); + USSresponse = await Upload.dirToUSSDir(dummySession, undefined as any, dsName); } catch (err) { error = err; } @@ -2229,7 +2231,7 @@ describe("z/OS Files - Upload", () => { it("should throw an error if USS directory is not specified", async () => { try { - USSresponse = await Upload.dirToUSSDir(dummySession, "some/path", undefined); + USSresponse = await Upload.dirToUSSDir(dummySession, "some/path", undefined as any); } catch (err) { error = err; } @@ -2253,11 +2255,11 @@ describe("z/OS Files - Upload", () => { it("should return with proper response", async () => { isDirSpy.mockReturnValueOnce(true); - isDirectoryExistsSpy.mockReturnValueOnce(true); + isDirectoryExistsSpy.mockReturnValueOnce(true as any); getFileListFromPathSpy.mockReturnValueOnce(["file1", "file2"]); fileToUssFileSpy.mockReturnValue(testReturn); fileToUssFileSpy.mockReturnValue(testReturn); - promiseSpy.mockReturnValueOnce({}); + promiseSpy.mockReturnValueOnce({} as any); try { USSresponse = await Upload.dirToUSSDir(dummySession, testPath, dsName); @@ -2271,11 +2273,11 @@ describe("z/OS Files - Upload", () => { }); it("should return with proper response with responseTimeout", async () => { isDirSpy.mockReturnValueOnce(true); - isDirectoryExistsSpy.mockReturnValueOnce(true); + isDirectoryExistsSpy.mockReturnValueOnce(true as any); getFileListFromPathSpy.mockReturnValueOnce(["file1", "file2"]); fileToUssFileSpy.mockReturnValue(testReturn); fileToUssFileSpy.mockReturnValue(testReturn); - promiseSpy.mockReturnValueOnce({}); + promiseSpy.mockReturnValueOnce({} as any); try { USSresponse = await Upload.dirToUSSDir(dummySession, testPath, dsName, {responseTimeout: 5}); @@ -2289,7 +2291,7 @@ describe("z/OS Files - Upload", () => { }); describe("scenarios with .zosattributes file", () => { - const MockZosAttributes = jest.fn(); + const MockZosAttributes = jest.fn(); const attributesMock = new MockZosAttributes(); const chtagSpy = jest.spyOn(Utilities,"chtag"); @@ -2300,7 +2302,7 @@ describe("z/OS Files - Upload", () => { chtagSpy.mockReturnValue(testReturn); isDirSpy.mockReturnValueOnce(true) .mockReturnValue(false); - isDirectoryExistsSpy.mockReturnValue(true); + isDirectoryExistsSpy.mockReturnValue(true as any); fileToUssFileSpy.mockReturnValue(testReturn); attributesMock.getFileTransferMode = jest.fn((filePath: string) => { @@ -2356,7 +2358,7 @@ describe("z/OS Files - Upload", () => { isDirSpy.mockImplementation((dirPath: string) => { return (dirPath.endsWith("dir")); }); - getFileListWithFsSpy.mockImplementation((dirPath: string) => { + getFileListWithFsSpy.mockImplementation(((dirPath: string) => { if (dirPath.endsWith("uploaddir")) { return ["uploadedfile"]; } else if (dirPath.endsWith("ignoredir")) { @@ -2364,7 +2366,7 @@ describe("z/OS Files - Upload", () => { } else { return ["uploaddir", "ignoredir"]; } - }); + }) as any); getFileListFromPathSpy.mockImplementation((dirPath: string) => { if (dirPath.endsWith("uploaddir")) { return ["uploadedfile"]; @@ -2443,14 +2445,14 @@ describe("z/OS Files - Upload", () => { const fileToUssFileSpy = jest.spyOn(Upload, "fileToUssFile"); beforeEach(() => { - USSresponse = undefined; + USSresponse = undefined as any; error = undefined; streamToUssFileSpy.mockReset(); - streamToUssFileSpy.mockImplementation(() => null); + streamToUssFileSpy.mockImplementation(() => null as any); fileToUssFileSpy.mockClear(); - fileToUssFileSpy.mockImplementation(() => null); + fileToUssFileSpy.mockImplementation(() => null as any); }); it("return with proper response when upload USS file using deprecated function - streamToUSSFile", async () => { @@ -2459,9 +2461,9 @@ describe("z/OS Files - Upload", () => { inputStream.push(null); const streamResponse: IZosFilesResponse = { success: true, - commandResponse: undefined, + commandResponse: undefined as any, apiResponse: undefined }; - streamToUssFileSpy.mockReturnValueOnce(streamResponse); + streamToUssFileSpy.mockReturnValueOnce(streamResponse as any); try { USSresponse = await Upload.streamToUSSFile(dummySession, dsName, inputStream); } catch (err) { @@ -2480,9 +2482,9 @@ describe("z/OS Files - Upload", () => { const inputFile = "/path/to/file1.txt"; const streamResponse: IZosFilesResponse = { success: true, - commandResponse: undefined, + commandResponse: undefined as any, apiResponse: undefined }; - fileToUssFileSpy.mockReturnValueOnce(streamResponse); + fileToUssFileSpy.mockReturnValueOnce(streamResponse as any); try { USSresponse = await Upload.fileToUSSFile(dummySession, dsName, inputFile); } catch (err) { diff --git a/packages/zosfiles/__tests__/__unit__/methods/utilities/Utilities.unit.test.ts b/packages/zosfiles/__tests__/__unit__/methods/utilities/Utilities.unit.test.ts index 86281ecb88..bbed3ad481 100644 --- a/packages/zosfiles/__tests__/__unit__/methods/utilities/Utilities.unit.test.ts +++ b/packages/zosfiles/__tests__/__unit__/methods/utilities/Utilities.unit.test.ts @@ -86,7 +86,7 @@ describe("USS utiliites", () => { }); it("should URI-encoded the path", async () => { - const restClientSpy = jest.spyOn(ZosmfRestClient, "putExpectBuffer").mockReturnValue({}); + const restClientSpy = jest.spyOn(ZosmfRestClient, "putExpectBuffer").mockReturnValue({} as any); response = await Utilities.chtag(dummySession,"/test file",Tag.TEXT,"ISO8859-1"); @@ -97,7 +97,7 @@ describe("USS utiliites", () => { }); async function testChtagExpectPayload(args: IChtagArgs, expectedPayload: any) { - const restClientSpy = jest.spyOn(ZosmfRestClient, "putExpectBuffer").mockReturnValue({}); + const restClientSpy = jest.spyOn(ZosmfRestClient, "putExpectBuffer").mockReturnValue({} as any); response = await Utilities.chtag(dummySession,"/testfile",args.type,args.codeset); @@ -128,7 +128,7 @@ describe("Utilities.putUSSPayload", () => { const payload = {request:"chtag", action:"list"}; const filename = "/u/myhlq/aFile.txt"; - const content = new Buffer(JSON.stringify({stdout:["m ISO8859-1 T=off /tmp/file"]})); + const content: any = new Buffer(JSON.stringify({stdout:["m ISO8859-1 T=off /tmp/file"]})); describe("putUSSPayload", () => { const zosmfExpectSecondSpy = jest.spyOn(ZosmfRestClient, "putExpectBuffer"); @@ -144,7 +144,7 @@ describe("Utilities.putUSSPayload", () => { // Test for NULL try { - response = await Utilities.putUSSPayload(dummySession, null, payload); + response = await Utilities.putUSSPayload(dummySession, null as any, payload); } catch (e) { caughtError = e; } @@ -159,7 +159,7 @@ describe("Utilities.putUSSPayload", () => { let caughtError; try { - response = await Utilities.putUSSPayload(dummySession, undefined, payload); + response = await Utilities.putUSSPayload(dummySession, undefined as any, payload); } catch (e) { caughtError = e; } @@ -237,7 +237,7 @@ describe("Utilities.putUSSPayload", () => { // Test for NULL try { - response = await Utilities.isFileTagBinOrAscii(dummySession, null); + response = await Utilities.isFileTagBinOrAscii(dummySession, null as any); } catch (e) { caughtError = e; } @@ -252,7 +252,7 @@ describe("Utilities.putUSSPayload", () => { let caughtError; try { - response = await Utilities.isFileTagBinOrAscii(dummySession, undefined); + response = await Utilities.isFileTagBinOrAscii(dummySession, undefined as any); } catch (e) { caughtError = e; } @@ -288,7 +288,7 @@ describe("Utilities.putUSSPayload", () => { let response; let caughtError; zosmfExpectSecondSpy.mockClear(); - const content1 = new Buffer(JSON.stringify({stdout:["m UTF-8 T=off /tmp/file"]})); + const content1: any = new Buffer(JSON.stringify({stdout:["m UTF-8 T=off /tmp/file"]})); zosmfExpectSecondSpy.mockImplementation(() => content1); try { response = await Utilities.isFileTagBinOrAscii(dummySession, filename); @@ -309,7 +309,7 @@ describe("Utilities.putUSSPayload", () => { let response; let caughtError; zosmfExpectSecondSpy.mockClear(); - const content1 = new Buffer(JSON.stringify({stdout:["b binary T=on /tmp/file"]})); + const content1: any = new Buffer(JSON.stringify({stdout:["b binary T=on /tmp/file"]})); zosmfExpectSecondSpy.mockImplementation(() => content1); try { response = await Utilities.isFileTagBinOrAscii(dummySession, filename); @@ -330,7 +330,7 @@ describe("Utilities.putUSSPayload", () => { let response; let caughtError; zosmfExpectSecondSpy.mockClear(); - const content1 = new Buffer(JSON.stringify({stdout:["- untagged T=on /tmp/file"]})); + const content1: any = new Buffer(JSON.stringify({stdout:["- untagged T=on /tmp/file"]})); zosmfExpectSecondSpy.mockImplementation(() => content1); try { response = await Utilities.isFileTagBinOrAscii(dummySession, filename); @@ -351,7 +351,7 @@ describe("Utilities.putUSSPayload", () => { let response; let caughtError; zosmfExpectSecondSpy.mockClear(); - const content1 = new Buffer(JSON.stringify({})); + const content1: any = new Buffer(JSON.stringify({})); zosmfExpectSecondSpy.mockImplementation(() => content1); try { response = await Utilities.isFileTagBinOrAscii(dummySession, filename); @@ -383,7 +383,7 @@ describe("renameUSSFile", () => { it("should fail if new file path is not passed in", async () => { let error: Error; try { - await Utilities.renameUSSFile(dummySession, "/u/zowe/test", undefined); + await Utilities.renameUSSFile(dummySession, "/u/zowe/test", undefined as any); } catch (err) { error = err; } @@ -394,7 +394,7 @@ describe("renameUSSFile", () => { it("should execute if all parameters are provided", async () => { let error: Error; let renameResponse; - jest.spyOn(ZosmfRestClient, "putExpectBuffer").mockReturnValue({}); + jest.spyOn(ZosmfRestClient, "putExpectBuffer").mockReturnValue({} as any); const zosmfExpectSecondSpy = jest.spyOn(Utilities, "putUSSPayload"); const oldPath = "/u/zowe/test"; const newPath= "/u/zowe/test1"; diff --git a/packages/zosfiles/__tests__/__unit__/utils/ZosFilesUtils.unit.test.ts b/packages/zosfiles/__tests__/__unit__/utils/ZosFilesUtils.unit.test.ts index 0af880fa1e..bbf02e81da 100644 --- a/packages/zosfiles/__tests__/__unit__/utils/ZosFilesUtils.unit.test.ts +++ b/packages/zosfiles/__tests__/__unit__/utils/ZosFilesUtils.unit.test.ts @@ -72,7 +72,7 @@ describe("ZosFilesUtils", () => { isDirSpy.mockReturnValueOnce(false); lstatSyncSpy.mockReturnValueOnce({ isFile: jest.fn().mockReturnValue(true) - }); + } as any); expect(ZosFilesUtils.getFileListFromPath(inputPath).toString()).toBe(expectResult.toString()); }); @@ -83,7 +83,7 @@ describe("ZosFilesUtils", () => { isDirSpy.mockReturnValueOnce(false); lstatSyncSpy.mockReturnValueOnce({ isFile: jest.fn().mockReturnValue(true) - }); + } as any); expect(ZosFilesUtils.getFileListFromPath(inputPath, false).toString()).toBe(expectResult.toString()); }); @@ -92,10 +92,10 @@ describe("ZosFilesUtils", () => { const mockFileList = ["file1", "file2"]; isDirSpy.mockReturnValueOnce(true); - readDirSyncSpy.mockReturnValueOnce(mockFileList); + readDirSyncSpy.mockReturnValueOnce(mockFileList as any); lstatSyncSpy.mockReturnValue({ isFile: jest.fn().mockReturnValue(true) - }); + } as any); expect(ZosFilesUtils.getFileListFromPath(inputPath, false).toString()).toBe(mockFileList.toString()); }); @@ -108,10 +108,10 @@ describe("ZosFilesUtils", () => { ]; isDirSpy.mockReturnValueOnce(true); - readDirSyncSpy.mockReturnValueOnce(mockFileList); + readDirSyncSpy.mockReturnValueOnce(mockFileList as any); lstatSyncSpy.mockReturnValue({ isFile: jest.fn().mockReturnValue(true) - }); + } as any); expect(ZosFilesUtils.getFileListFromPath(inputPath).toString()).toBe(expectResult.toString()); }); @@ -121,10 +121,10 @@ describe("ZosFilesUtils", () => { const expectResult = ["file1"]; isDirSpy.mockReturnValueOnce(true); - readDirSyncSpy.mockReturnValueOnce(mockFileList); + readDirSyncSpy.mockReturnValueOnce(mockFileList as any); lstatSyncSpy.mockReturnValue({ isFile: jest.fn().mockReturnValue(true) - }); + } as any); expect(ZosFilesUtils.getFileListFromPath(inputPath, false, false).toString()).toBe(mockFileList.toString()); }); diff --git a/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts b/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts index 4493184a2c..b60100834e 100644 --- a/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts +++ b/packages/zosjobs/__tests__/__system__/MonitorJobs.system.test.ts @@ -337,7 +337,7 @@ describe("System Tests - Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (session, parms) => { return ORIG_JOBS_STATUS(session, parms); }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; // check that the status is input const status = await MonitorJobs.waitForStatusCommon(REAL_SESSION, @@ -373,7 +373,7 @@ describe("System Tests - Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (session, parms) => { return ORIG_JOBS_STATUS(session, parms); }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; // check that the status is active const status = await MonitorJobs.waitForStatusCommon(REAL_SESSION, @@ -409,7 +409,7 @@ describe("System Tests - Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (session, parms) => { return ORIG_JOBS_STATUS(session, parms); }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; // check that the status is output const status = await MonitorJobs.waitForStatusCommon(REAL_SESSION, @@ -440,7 +440,7 @@ describe("System Tests - Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (session, parms) => { return ORIG_JOBS_STATUS(session, parms); }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; // submit the job SubmitJobs.submitJcl(REAL_SESSION, renderedJcl).then((jobInfo) => { @@ -498,7 +498,7 @@ describe("System Tests - Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (session, parms) => { return ORIG_JOBS_STATUS(session, parms); }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; // submit the job SubmitJobs.submitJcl(REAL_SESSION, renderedJcl).then((jobInfo) => { diff --git a/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts index 25f20b1322..d0370db9db 100644 --- a/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/CancelJobs.unit.test.ts @@ -46,7 +46,7 @@ describe("Cancel Jobs unit tests", () => { describe("Positive tests", () => { it("should allow users to call cancelJob with correct parameters", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(returnCancelJobsDataAsync); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(returnCancelJobsDataAsync); let caughtError; let response; try { @@ -59,7 +59,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should allow users to call cancelJobForJob with correct parameters", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(returnCancelJobsDataAsync); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(returnCancelJobsDataAsync); let caughtError; let response; try { @@ -72,7 +72,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should allow users to call cancelJobForJob with correct parameters (with version 1_0)", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { expect(body).toMatchSnapshot(); return CancelJobsData.SAMPLE_JOB_FEEDBACK_ASYNC; }); @@ -81,7 +81,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should allow users to call cancelJobForJob with correct parameters (with version 2_0)", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { expect(body).toMatchSnapshot(); return CancelJobsData.SAMPLE_JOB_FEEDBACK_GOOD; }); @@ -90,7 +90,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should allow users to call cancelJobForJob with correct parameters (with version 2_0) and get a bad response", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { expect(body).toMatchSnapshot(); return CancelJobsData.SAMPLE_JOB_FEEDBACK_BAD; }); @@ -99,7 +99,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should allow users to call cancelJobCommon with correct parameters", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(returnCancelJobsDataAsync); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(returnCancelJobsDataAsync); let caughtError; let response; try { @@ -112,7 +112,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should allow users to call cancelJobCommon with correct parameters (with version 1_0)", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { expect(body).toMatchSnapshot(); return CancelJobsData.SAMPLE_JOB_FEEDBACK_ASYNC; }); @@ -121,7 +121,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should allow users to call cancelJobCommon with correct parameters (with version 2_0)", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { expect(body).toMatchSnapshot(); return CancelJobsData.SAMPLE_JOB_FEEDBACK_GOOD; }); @@ -130,7 +130,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should allow users to call cancelJobCommon with correct parameters (with version 2_0) and get a failed response", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn(async (session: any, resource: string, headers: any[], body: any) => { expect(body).toMatchSnapshot(); return CancelJobsData.SAMPLE_JOB_FEEDBACK_BAD; }); @@ -141,7 +141,7 @@ describe("Cancel Jobs unit tests", () => { describe("Error handling tests - async/await", () => { it("should be able to catch errors from cancelJob with async/await syntax", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); let err: Error | ImperativeError; try { await CancelJobs.cancelJob(fakeSession, "MYJOB1", "JOB0000"); @@ -154,7 +154,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should be able to catch errors from cancelJobForJob with async/await syntax", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); let err: Error | ImperativeError; try { await CancelJobs.cancelJobForJob(fakeSession, fakeJob); @@ -167,7 +167,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should be able to catch errors from cancelJobCommon with async/await syntax", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); let err: Error | ImperativeError; try { await CancelJobs.cancelJobCommon(fakeSession, { @@ -186,7 +186,7 @@ describe("Cancel Jobs unit tests", () => { describe("Error handling tests - Promise catch() syntax", () => { /* eslint-disable jest/no-done-callback */ it("should be able to catch errors from cancelJob with Promise.catch() syntax", (done: any) => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); CancelJobs.cancelJob(fakeSession, "MYJOB1", "JOB0000").then(() => { expect(".catch() should have been called").toEqual("test failed"); }).catch((err) => { @@ -198,7 +198,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should be able to catch errors from cancelJobForJob with Promise.catch() syntax", (done: any) => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); CancelJobs.cancelJobForJob(fakeSession, fakeJob) .then(() => { expect(".catch() should have been called").toEqual("test failed"); @@ -211,7 +211,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should be able to catch errors from cancelJobCommon with Promise.catch() syntax", (done: any) => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); CancelJobs.cancelJobCommon(fakeSession, { jobname: "MYJOB1", jobid: "JOB0001" @@ -230,7 +230,7 @@ describe("Cancel Jobs unit tests", () => { describe("Parameter validation", () => { it("should reject calls to cancelJob that omit jobname", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); let err: Error | ImperativeError; try { await CancelJobs.cancelJob(fakeSession, undefined, "JOB0000"); @@ -243,7 +243,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should reject calls to cancelJob that omit jobid", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); let err: Error | ImperativeError; try { await CancelJobs.cancelJob(fakeSession, "MYJOB1", undefined); @@ -256,7 +256,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should reject calls to cancelJobForJob that omit jobname", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); let err: Error | ImperativeError; const badJob: IJob = JSON.parse(JSON.stringify(fakeJob)); delete badJob.jobname; @@ -271,7 +271,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should reject calls to cancelJobForJob that omit jobid", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); let err: Error | ImperativeError; const badJob: IJob = JSON.parse(JSON.stringify(fakeJob)); delete badJob.jobid; @@ -286,7 +286,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should reject calls to cancelJobCommon that omit jobname from the parms object", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); let err: Error | ImperativeError; try { await CancelJobs.cancelJobCommon(fakeSession, { @@ -302,7 +302,7 @@ describe("Cancel Jobs unit tests", () => { }); it("should reject calls to cancelJobCommon that omit jobid from the parms object", async () => { - ZosmfRestClient.putExpectJSON = jest.fn(throwImperativeError); + (ZosmfRestClient.putExpectJSON as any) = jest.fn(throwImperativeError); let err: Error | ImperativeError; try { await CancelJobs.cancelJobCommon(fakeSession, { diff --git a/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts index e365beab50..3b36da8cd8 100644 --- a/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/DeleteJobs.unit.test.ts @@ -46,7 +46,7 @@ describe("Delete Jobs unit tests", () => { describe("Positive tests", () => { it("should allow users to call deleteJob with correct parameters", async () => { - ZosmfRestClient.deleteExpectJSON = jest.fn(returnDeleteJobsDataAsync); + ZosmfRestClient.deleteExpectJSON = jest.fn(returnDeleteJobsDataAsync) as any; let caughtError; let response; try { @@ -59,7 +59,7 @@ describe("Delete Jobs unit tests", () => { }); it("should allow users to call deleteJobForJob with correct parameters", async () => { - ZosmfRestClient.deleteExpectJSON = jest.fn(returnDeleteJobsDataAsync); + ZosmfRestClient.deleteExpectJSON = jest.fn(returnDeleteJobsDataAsync) as any; let caughtError; let response; try { @@ -75,7 +75,7 @@ describe("Delete Jobs unit tests", () => { ZosmfRestClient.deleteExpectJSON = jest.fn(async (session: any, resource: string, headers: any[]) => { expect(headers).toContain(ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_1); return CancelJobsData.SAMPLE_JOB_FEEDBACK_ASYNC; - }); + }) as any; const response = await DeleteJobs.deleteJobForJob(fakeSession, fakeJob, "1.0"); expect(response).toEqual(CancelJobsData.SAMPLE_JOB_FEEDBACK_ASYNC); }); @@ -84,7 +84,7 @@ describe("Delete Jobs unit tests", () => { ZosmfRestClient.deleteExpectJSON = jest.fn(async (session: any, resource: string, headers: any[]) => { expect(headers).toContain(ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_2); return CancelJobsData.SAMPLE_JOB_FEEDBACK_GOOD; - }); + }) as any; const response = await DeleteJobs.deleteJobForJob(fakeSession, fakeJob, "2.0"); expect(response).toEqual(CancelJobsData.SAMPLE_JOB_FEEDBACK_GOOD); }); @@ -93,13 +93,13 @@ describe("Delete Jobs unit tests", () => { ZosmfRestClient.deleteExpectJSON = jest.fn(async (session: any, resource: string, headers: any[]) => { expect(headers).toContain(ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_2); return CancelJobsData.SAMPLE_JOB_FEEDBACK_BAD; - }); + }) as any; const response = await DeleteJobs.deleteJobForJob(fakeSession, fakeJob, "2.0"); expect(response).toEqual(CancelJobsData.SAMPLE_JOB_FEEDBACK_BAD); }); it("should allow users to call deleteJobCommon with correct parameters", async () => { - ZosmfRestClient.deleteExpectJSON = jest.fn(returnDeleteJobsDataAsync); + ZosmfRestClient.deleteExpectJSON = jest.fn(returnDeleteJobsDataAsync) as any; let caughtError; let response; try { @@ -115,7 +115,7 @@ describe("Delete Jobs unit tests", () => { ZosmfRestClient.deleteExpectJSON = jest.fn(async (session: any, resource: string, headers: any[]) => { expect(headers).toContain(ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_1); return CancelJobsData.SAMPLE_JOB_FEEDBACK_ASYNC; - }); + }) as any; const response = await DeleteJobs.deleteJobCommon(fakeSession, {jobname: "MYJOB1", jobid: "JOB00001", modifyVersion: "1.0"}); expect(response).toEqual(CancelJobsData.SAMPLE_JOB_FEEDBACK_ASYNC); }); @@ -124,7 +124,7 @@ describe("Delete Jobs unit tests", () => { ZosmfRestClient.deleteExpectJSON = jest.fn(async (session: any, resource: string, headers: any[]) => { expect(headers).toContain(ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_2); return CancelJobsData.SAMPLE_JOB_FEEDBACK_GOOD; - }); + }) as any; const response = await DeleteJobs.deleteJobCommon(fakeSession, {jobname: "MYJOB1", jobid: "JOB00001", modifyVersion: "2.0"}); expect(response).toEqual(CancelJobsData.SAMPLE_JOB_FEEDBACK_GOOD); }); @@ -133,7 +133,7 @@ describe("Delete Jobs unit tests", () => { ZosmfRestClient.deleteExpectJSON = jest.fn(async (session: any, resource: string, headers: any[]) => { expect(headers).toContain(ZosmfHeaders.X_IBM_JOB_MODIFY_VERSION_2); return CancelJobsData.SAMPLE_JOB_FEEDBACK_BAD; - }); + }) as any; const response = await DeleteJobs.deleteJobCommon(fakeSession, {jobname: "MYJOB1", jobid: "JOB00001", modifyVersion: "2.0"}); expect(response).toEqual(CancelJobsData.SAMPLE_JOB_FEEDBACK_BAD); }); diff --git a/packages/zosjobs/__tests__/__unit__/DownloadJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/DownloadJobs.unit.test.ts index 1ed3314c34..258a5c7310 100644 --- a/packages/zosjobs/__tests__/__unit__/DownloadJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/DownloadJobs.unit.test.ts @@ -34,7 +34,7 @@ describe("DownloadJobs", () => { IO.createWriteStream = jest.fn((file: string) => { // do nothing; - }); + }) as any; const expectedMockSpoolContent = "Hello! This is my spool content."; const fakeSession: any = {}; @@ -65,7 +65,7 @@ describe("DownloadJobs", () => { }); it("should allow users to call downloadSpoolContent with correct parameters", async () => { - ZosmfRestClient.getStreamed = jest.fn(async (session: AbstractSession, resource: string, reqHeaders?: any[]) => { + (ZosmfRestClient.getStreamed as any) = jest.fn(async (session: AbstractSession, resource: string, reqHeaders?: any[]) => { // do nothing }); IO.createDirsSyncFromFilePath = jest.fn((directory: string) => { @@ -112,9 +112,9 @@ describe("DownloadJobs", () => { it("should allow users to call downloadSpoolContentCommon with correct parameters " + "(jobFile with no procstep - procstep should be omitted from the download directory)", async () => { - ZosmfRestClient.getStreamed = jest.fn(async (session: AbstractSession, resource: string, reqHeaders?: any[]) => { + (ZosmfRestClient.getStreamed as any) = jest.fn(async (session: AbstractSession, resource: string, reqHeaders?: any[]) => { // do nothing - }); + }) as any; IO.createDirsSyncFromFilePath = jest.fn((directory: string) => { // do nothing; }); @@ -130,9 +130,9 @@ describe("DownloadJobs", () => { }); it("should allow users to call downloadSpoolContentCommon with correct parameters (default output directory)", async () => { - ZosmfRestClient.getStreamed = jest.fn(async (session: AbstractSession, resource: string, reqHeaders?: any[]) => { + (ZosmfRestClient.getStreamed as any) = jest.fn(async (session: AbstractSession, resource: string, reqHeaders?: any[]) => { // do nothing; - }); + }) as any; IO.createDirsSyncFromFilePath = jest.fn((directory: string) => { // do nothing; }); @@ -146,9 +146,9 @@ describe("DownloadJobs", () => { it("should allow users to call downloadSpoolContentCommon with correct parameters (omitting job ID in the resulting directory)", async () => { - ZosmfRestClient.getStreamed = jest.fn(async (session: AbstractSession, resource: string, reqHeaders?: any[]) => { + (ZosmfRestClient.getStreamed as any) = jest.fn(async (session: AbstractSession, resource: string, reqHeaders?: any[]) => { // do nothing - }); + }) as any; IO.createDirsSyncFromFilePath = jest.fn((directory: string) => { // do nothing; }); @@ -164,7 +164,7 @@ describe("DownloadJobs", () => { }); describe("Error catching - async/ await", () => { it("should be able to catch errors thrown by ZosmfRestClient in downloadAllSpoolContentCommon with async/await syntax", async () => { - ZosmfRestClient.getStreamed = jest.fn(throwError); + (ZosmfRestClient.getStreamed as any) = jest.fn(throwError); let err: Error | ImperativeError; try { await DownloadJobs.downloadAllSpoolContentCommon(fakeSession, { @@ -180,7 +180,7 @@ describe("DownloadJobs", () => { }); it("should be able to catch errors thrown by ZosmfRestClient in downloadSpoolContentCommon with async/await syntax", async () => { - ZosmfRestClient.getStreamed = jest.fn(throwError); + (ZosmfRestClient.getStreamed as any) = jest.fn(throwError); let err: Error | ImperativeError; try { await DownloadJobs.downloadSpoolContentCommon(fakeSession, { @@ -195,7 +195,7 @@ describe("DownloadJobs", () => { }); it("should be able to catch errors thrown by ZosmfRestClient in downloadSpoolContent with async/await syntax", async () => { - ZosmfRestClient.getStreamed = jest.fn(throwError); + (ZosmfRestClient.getStreamed as any) = jest.fn(throwError); let err: Error | ImperativeError; try { await DownloadJobs.downloadSpoolContent(fakeSession, @@ -241,7 +241,7 @@ describe("DownloadJobs", () => { }); it("should be able to catch errors thrown by ZosmfRestClient in downloadSpoolContent with Promise.catch() syntax", (done: any) => { - ZosmfRestClient.getStreamed = jest.fn(throwError); + (ZosmfRestClient.getStreamed as any) = jest.fn(throwError); DownloadJobs.downloadSpoolContent(fakeSession, jobFiles[0] ).then(() => { diff --git a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts index f0f5956238..96ec8a22c2 100644 --- a/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts @@ -17,7 +17,7 @@ import { GetJobsData } from "../__resources__/api/GetJobsData"; const pretendSession = new Session({user: "test", password: "test", hostname: "Test"}); function mockGetJobsJSONData(data: object) { - const mock = jest.fn((session: AbstractSession, resource: string, headers?: any[]): Promise => { + const mock = jest.fn((session: AbstractSession, resource: string, headers?: any[]): Promise => { return new Promise((resolve, reject) => { ProcessUtils.nextTick(() => { resolve(data); @@ -28,7 +28,7 @@ function mockGetJobsJSONData(data: object) { } function mockGetJobsStringData(data: string) { - const mock = jest.fn((session: AbstractSession, resource: string, headers?: any[]): Promise => { + const mock = jest.fn((session: AbstractSession, resource: string, headers?: any[]): Promise => { return new Promise((resolve, reject) => { ProcessUtils.nextTick(() => { resolve(data); @@ -40,7 +40,7 @@ function mockGetJobsStringData(data: string) { // this mock only tests API rejection of promises by ZosmfRestClient function mockGetJobsServerError(errorCode: string, causeErrors: string) { - const mock = jest.fn((session: AbstractSession, resource: string, headers?: any[]): Promise => { + const mock = jest.fn((session: AbstractSession, resource: string, headers?: any[]): Promise => { return new Promise((resolve, reject) => { ProcessUtils.nextTick(() => { reject(new ImperativeError({ @@ -271,7 +271,7 @@ describe("GetJobs tests", () => { it("should have proper URI when using no parms", () => { (ZosmfRestClient.getExpectJSON as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getJobsCommon(pretendSession, {}); @@ -279,7 +279,7 @@ describe("GetJobs tests", () => { it("should have proper URI when using prefix", () => { (ZosmfRestClient.getExpectJSON as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getJobsCommon(pretendSession, {prefix: "fakePrefix"}); @@ -287,7 +287,7 @@ describe("GetJobs tests", () => { it("should have proper URI when using owner", () => { (ZosmfRestClient.getExpectJSON as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getJobsCommon(pretendSession, {owner: "fakeOwner"}); @@ -295,7 +295,7 @@ describe("GetJobs tests", () => { it("should have proper URI when using maxjobs", () => { (ZosmfRestClient.getExpectJSON as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getJobsCommon(pretendSession, {maxJobs: 10}); @@ -303,7 +303,7 @@ describe("GetJobs tests", () => { it("should have proper URI when using jobid", () => { (ZosmfRestClient.getExpectJSON as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getJobsCommon(pretendSession, {jobid: "fakeJobid"}); @@ -311,7 +311,7 @@ describe("GetJobs tests", () => { it("should have proper URI when using jobname and jobid", () => { (ZosmfRestClient.getExpectJSON as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getJobsByOwnerAndPrefix(pretendSession, "someOwner", "somePrefix"); @@ -319,7 +319,7 @@ describe("GetJobs tests", () => { it("should have proper URI when using jobname, prefix, and jobid", () => { (ZosmfRestClient.getExpectJSON as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getJobsCommon(pretendSession, {jobid: "fakeJobid", prefix: "somePrefix", owner: "someOwner"}); @@ -327,7 +327,7 @@ describe("GetJobs tests", () => { it("should have proper URI when using all parms", () => { (ZosmfRestClient.getExpectJSON as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getJobsCommon(pretendSession, {owner: "fakeOwner", prefix: "fakePrefix", maxJobs: 2, jobid: "fakeID"}); @@ -365,7 +365,7 @@ describe("GetJobs tests", () => { describe("getJcl APIs", () => { it("should have proper URI when getting JCL", () => { (ZosmfRestClient.getExpectString as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getJcl(pretendSession, "fakeJob", "fakeId"); @@ -401,7 +401,7 @@ describe("GetJobs tests", () => { describe("getSpoolFiles APIs", () => { it("should have proper URI when getting spool files", () => { (ZosmfRestClient.getExpectJSON as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getSpoolFiles(pretendSession, "fakeJob", "fakeId"); @@ -437,7 +437,7 @@ describe("GetJobs tests", () => { describe("getSpoolContent APIs", () => { it("should have proper URI when getting spool content", () => { (ZosmfRestClient.getExpectString as any) = - jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { + jest.fn((session: AbstractSession, resource: string, headers?: any[]) => { expect(resource).toMatchSnapshot(); }); GetJobs.getSpoolContent(pretendSession, GetJobsData.SAMPLE_JOB_FILE); diff --git a/packages/zosjobs/__tests__/__unit__/MonitorJobs.test.ts b/packages/zosjobs/__tests__/__unit__/MonitorJobs.test.ts index ee8744fae7..ea7de54f55 100644 --- a/packages/zosjobs/__tests__/__unit__/MonitorJobs.test.ts +++ b/packages/zosjobs/__tests__/__unit__/MonitorJobs.test.ts @@ -132,7 +132,7 @@ describe("Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; const response = await MonitorJobs.waitForOutputStatus(new Session({hostname: "fake", port: 443}), "FAKE", "FAKE"); expect(response).toMatchSnapshot(); @@ -145,7 +145,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { throw new ImperativeError({msg: ERROR_MSG}); }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -167,7 +167,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { throw new ImperativeError({msg: ERROR_MSG}); }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; MonitorJobs.waitForOutputStatus(new Session({hostname: "fake", port: 443}), "FAKE", "FAKE").then((response) => { done("Monitor jobs should not have fulfilled the promise because getJobs should have thrown and error"); @@ -189,7 +189,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "INPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; // "Mock" the attempts value Object.defineProperty(MonitorJobs, "DEFAULT_ATTEMPTS", {value: attempts}); @@ -227,7 +227,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -253,7 +253,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -280,7 +280,7 @@ describe("Monitor Jobs", () => { throw new ImperativeError({msg: ERROR_MSG}); } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -308,7 +308,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: undefined}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -430,7 +430,7 @@ describe("Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; // IJob requires more fields to be populated - fake it out with only the required here. const iJobParms: any = {jobname: "FAKE", jobid: "FAKE"}; @@ -446,7 +446,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { throw new ImperativeError({msg: ERROR_MSG}); }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; const iJobParms: any = {jobname: "FAKE", jobid: "FAKE"}; MonitorJobs.waitForJobOutputStatus(new Session({hostname: "fake", port: 443}), iJobParms).then((response) => { @@ -466,7 +466,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { throw new ImperativeError({msg: ERROR_MSG}); }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -492,7 +492,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "INPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; // "Mock" the attempts value Object.defineProperty(MonitorJobs, "DEFAULT_ATTEMPTS", {value: attempts}); @@ -532,7 +532,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -560,7 +560,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -589,7 +589,7 @@ describe("Monitor Jobs", () => { throw new ImperativeError({msg: ERROR_MSG}); } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -619,7 +619,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: undefined}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -816,7 +816,7 @@ describe("Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; const response = await MonitorJobs.waitForStatusCommon(new Session({hostname: "fake", port: 443}), {jobname: "FAKE", jobid: "FAKE"}); @@ -830,7 +830,7 @@ describe("Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; const response = await MonitorJobs.waitForStatusCommon(new Session({hostname: "fake", port: 443}), {jobname: "FAKE", jobid: "FAKE", status: "ACTIVE"}); @@ -844,7 +844,7 @@ describe("Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "ACTIVE"}; }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; const response = await MonitorJobs.waitForStatusCommon(new Session({hostname: "fake", port: 443}), {jobname: "FAKE", jobid: "FAKE", status: "INPUT"}); @@ -858,7 +858,7 @@ describe("Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "ACTIVE"}; }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; const response = await MonitorJobs.waitForStatusCommon(new Session({hostname: "fake", port: 443}), {jobname: "FAKE", jobid: "FAKE", status: "ACTIVE"}); @@ -872,7 +872,7 @@ describe("Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; const response = await MonitorJobs.waitForStatusCommon(new Session({hostname: "fake", port: 443}), {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}); @@ -886,7 +886,7 @@ describe("Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; const response = await MonitorJobs.waitForStatusCommon(new Session({hostname: "fake", port: 443}), {jobname: "FAKE", jobid: "FAKE", status: "INPUT"}); @@ -900,7 +900,7 @@ describe("Monitor Jobs", () => { const mockedGetJobs = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "INPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobs; + GetJobs.getStatusCommon = mockedGetJobs as any; const response = await MonitorJobs.waitForStatusCommon(new Session({hostname: "fake", port: 443}), {jobname: "FAKE", jobid: "FAKE", status: "INPUT"}); @@ -914,7 +914,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { throw new ImperativeError({msg: ERROR_MSG}); }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -937,7 +937,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { throw new ImperativeError({msg: ERROR_MSG}); }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; MonitorJobs.waitForStatusCommon(new Session({hostname: "fake", port: 443}), {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}).then((response) => { @@ -958,7 +958,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { throw new Error(ERROR_MSG); }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; MonitorJobs.waitForStatusCommon(new Session({hostname: "fake", port: 443}), {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}).then((response) => { @@ -981,7 +981,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "INPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; try { @@ -1003,7 +1003,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "INPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; try { @@ -1025,7 +1025,7 @@ describe("Monitor Jobs", () => { const mockedGetJobsCommon = jest.fn(async (args) => { return {jobname: "FAKE", jobid: "FAKE", status: "INPUT"}; }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; @@ -1062,7 +1062,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: "ACTIVE"}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -1089,7 +1089,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -1116,7 +1116,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: "OUTPUT"}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -1144,7 +1144,7 @@ describe("Monitor Jobs", () => { throw new ImperativeError({msg: ERROR_MSG}); } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; @@ -1173,7 +1173,7 @@ describe("Monitor Jobs", () => { return {jobname: "FAKE", jobid: "FAKE", status: undefined}; } }); - GetJobs.getStatusCommon = mockedGetJobsCommon; + GetJobs.getStatusCommon = mockedGetJobsCommon as any; let error; let response; diff --git a/packages/zosjobs/__tests__/__unit__/MonitorJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/MonitorJobs.unit.test.ts index c2484976f8..793ff9ed3e 100644 --- a/packages/zosjobs/__tests__/__unit__/MonitorJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/MonitorJobs.unit.test.ts @@ -366,7 +366,7 @@ describe("MonitorJobs", () => { status : "COMPLETE" }; - const sleepMock = sleep as jest.Mock; + const sleepMock = sleep as any as jest.Mock; beforeEach(() => { checkStatusSpy.mockReset(); @@ -374,9 +374,9 @@ describe("MonitorJobs", () => { // Reset the mock and program it to return immediately. sleepMock.mockReset(); - sleepMock.mockImplementation(() => { + sleepMock.mockImplementation((() => { return; - }); + }) as any); }); afterAll(() => { @@ -482,12 +482,12 @@ describe("MonitorJobs", () => { }; checkStatusSpy.mockReturnValue([false, dummyJob]); - sleepMock.mockImplementation(() => { + sleepMock.mockImplementation((() => { attempts++; if (attempts === maxAttempts) { throw Error(errMsg); } - }); + }) as any); let error: Error; @@ -525,7 +525,7 @@ describe("MonitorJobs", () => { }); describe("checkStatus", () => { - const getStatusCommonMock = GetJobs.getStatusCommon as jest.Mock; + const getStatusCommonMock = GetJobs.getStatusCommon as any as jest.Mock; beforeEach(() => { getStatusCommonMock.mockReset(); @@ -540,7 +540,7 @@ describe("MonitorJobs", () => { status: "ACTIVE" }; - getStatusCommonMock.mockReturnValue(job); + getStatusCommonMock.mockReturnValue(job as any); let response: [boolean, IJob]; @@ -570,7 +570,7 @@ describe("MonitorJobs", () => { status: "ACTIVE" }; - getStatusCommonMock.mockReturnValue(job); + getStatusCommonMock.mockReturnValue(job as any); // The first call is for if the job status is equal to parms const response: [boolean, IJob] = await privateMonitorJobs.checkStatus({}, parms); @@ -589,7 +589,7 @@ describe("MonitorJobs", () => { status: "ACTIVE" }; - getStatusCommonMock.mockReturnValue(job); + getStatusCommonMock.mockReturnValue(job as any); let error: Error; diff --git a/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts b/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts index 6b13d43568..66bed0c482 100644 --- a/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts +++ b/packages/zosjobs/__tests__/__unit__/SubmitJobs.unit.test.ts @@ -78,7 +78,7 @@ describe("Submit Jobs API", () => { jobToWaitFor.status = "OUTPUT"; jobToWaitFor.retcode = "CC 0000"; return jobToWaitFor; - }); + }) as any; const finishedJob = await SubmitJobs.checkSubmitOptions(fakeSession, { waitForOutput: true, jclSource: "dataset" @@ -99,7 +99,7 @@ describe("Submit Jobs API", () => { jobToWaitFor.status = "ACTIVE"; jobToWaitFor.retcode = null; return jobToWaitFor; - }); + }) as any; const finishedJob = await SubmitJobs.checkSubmitOptions(fakeSession, { waitForActive: true, jclSource: "dataset" @@ -586,7 +586,7 @@ describe("Submit Jobs API", () => { it("should allow users to call submitJCLCommon with jcl substitution", async () => { let receivedHeaders: IHeaderContent[] = []; - (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { + (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { receivedHeaders = headers; return returnIJob(); }); @@ -603,7 +603,7 @@ describe("Submit Jobs API", () => { it("should allow users to call submitJCLNotifyCommon with jcl substitution", async () => { (MonitorJobs as any).waitForStatusCommon = returnIJob; // mock monitor job API used by SubmitJobs.ts let receivedHeaders: IHeaderContent[] = []; - (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { + (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { receivedHeaders = headers; return returnIJob(); }); @@ -623,7 +623,7 @@ describe("Submit Jobs API", () => { it("should allow users to call submitDataSetJobCommon with jcl substitution", async () => { let receivedHeaders: IHeaderContent[] = []; - (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { + (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { receivedHeaders = headers; return returnIJob(); }); @@ -639,7 +639,7 @@ describe("Submit Jobs API", () => { it("should allow users to call submitJobNotifyCommon with jcl substitution", async () => { let receivedHeaders: IHeaderContent[] = []; - (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { + (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { receivedHeaders = headers; return returnIJob(); }); @@ -656,7 +656,7 @@ describe("Submit Jobs API", () => { it("should permit multiple spaces as symbol definition delimiters", async () => { let receivedHeaders: IHeaderContent[] = []; - (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { + (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { receivedHeaders = headers; return returnIJob(); }); @@ -672,7 +672,7 @@ describe("Submit Jobs API", () => { it("should permit two single quotes inside a single quoted value", async () => { let receivedHeaders: IHeaderContent[] = []; - (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { + (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { receivedHeaders = headers; return returnIJob(); }); @@ -687,7 +687,7 @@ describe("Submit Jobs API", () => { it("should permit two single quotes when value is not quoted", async () => { let receivedHeaders: IHeaderContent[] = []; - (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { + (ZosmfRestClient as any).putExpectJSON = jest.fn((session, url, headers, payload): Promise => { receivedHeaders = headers; return returnIJob(); }); diff --git a/packages/zoslogs/__tests__/__unit__/GetZosLog.unit.test.ts b/packages/zoslogs/__tests__/__unit__/GetZosLog.unit.test.ts index c546e7a830..b47834fe73 100644 --- a/packages/zoslogs/__tests__/__unit__/GetZosLog.unit.test.ts +++ b/packages/zoslogs/__tests__/__unit__/GetZosLog.unit.test.ts @@ -59,7 +59,7 @@ describe("GetZosLog getResourcePath", () => { describe("GetZosLog getZosLog", () => { it("should succeed and return logs", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(GetZosLogsData.SAMPLE_RESP_DATA); @@ -82,7 +82,7 @@ describe("GetZosLog getZosLog", () => { }); it("should succeed and return unprocessed logs", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(GetZosLogsData.SAMPLE_RESP_DATA); diff --git a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts index 0f88a2613a..921fc320ed 100644 --- a/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/IssueTso.unit.test.ts @@ -115,7 +115,7 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { let error: ImperativeError; let response: ISendResponse; - jest.spyOn(StartTso, "start").mockResolvedValueOnce({ success: false }); + jest.spyOn(StartTso, "start").mockResolvedValueOnce({ success: false } as any); try { response = await IssueTso.issueTsoCommand(PRETEND_SESSION, "acc", "command"); @@ -131,28 +131,28 @@ describe("TsoIssue issueTsoCommand - failing scenarios", () => { describe("TsoIssue issueTsoCommand", () => { it("should succeed", async () => { - (StartTso.start as any) = jest.fn((): Promise => { + (StartTso.start as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(START_RESPONSE); }); }); }); - (SendTso.getAllResponses as any) = jest.fn((): Promise => { + (SendTso.getAllResponses as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve({}); }); }); }); - (SendTso.sendDataToTSOCollect as any) = jest.fn((): Promise => { + (SendTso.sendDataToTSOCollect as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(SEND_RESPONSE); }); }); }); - (StopTso.stop as any) = jest.fn((): Promise => { + (StopTso.stop as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(null); @@ -172,7 +172,7 @@ describe("TsoIssue issueTsoCommand", () => { }); it("should succeed (with params)", async () => { - (IssueTso.issueTsoCommand as any) = jest.fn((): Promise => { + (IssueTso.issueTsoCommand as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve({}); diff --git a/packages/zostso/__tests__/__unit__/PingTso.unit.test.ts b/packages/zostso/__tests__/__unit__/PingTso.unit.test.ts index 969112daf6..fedd9a97b0 100644 --- a/packages/zostso/__tests__/__unit__/PingTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/PingTso.unit.test.ts @@ -62,7 +62,7 @@ function expectZosmfResponseFailed(response: IPingResponse, error: ImperativeErr describe("PingTsoCommand Test", () => { it("should return ping response if a correct servlet key was provided", async () => { - (ZosmfRestClient.putExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); @@ -84,7 +84,7 @@ describe("PingTsoCommand Test", () => { expectZosmfResponseSucceeded(response, error); }); it("should return response if an invalid servlet key was provided", async () => { - (ZosmfRestClient.putExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.putExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); diff --git a/packages/zostso/__tests__/__unit__/SendTso.unit.test.ts b/packages/zostso/__tests__/__unit__/SendTso.unit.test.ts index 6d4ebc8bfa..237b2041c3 100644 --- a/packages/zostso/__tests__/__unit__/SendTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/SendTso.unit.test.ts @@ -94,14 +94,14 @@ describe("TsoSend sendDataToTSOCollect - failing scenarios", () => { describe("TsoSend sendDataToTSOCollect", () => { it("should succeed", async () => { - (SendTso.sendDataToTSOCommon as any) = jest.fn((): Promise => { + (SendTso.sendDataToTSOCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); }); }); }); - (SendTso.getAllResponses as any) = jest.fn((): Promise => { + (SendTso.getAllResponses as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(SEND_RESPONSE); @@ -124,7 +124,7 @@ describe("TsoSend sendDataToTSOCollect", () => { describe("TsoSend getDataFromTSO", () => { it("should succeed", async () => { - (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.getExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve({}); diff --git a/packages/zostso/__tests__/__unit__/StartTso.unit.test.ts b/packages/zostso/__tests__/__unit__/StartTso.unit.test.ts index f21ac17edf..673354f6e7 100644 --- a/packages/zostso/__tests__/__unit__/StartTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/StartTso.unit.test.ts @@ -193,7 +193,7 @@ describe("StartTso getResourcesQuery", () => { describe("StartTso startCommon", () => { it("should succeed with correct parameters", async () => { - (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.postExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); @@ -239,14 +239,14 @@ describe("StartTso startCommon", () => { describe("StartTso start", () => { it("should succeed with all correctly provided parameters", async () => { - (StartTso.startCommon as any) = jest.fn((): Promise => { + (StartTso.startCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); }); }); }); - (SendTso.getAllResponses as any) = jest.fn((): Promise => { + (SendTso.getAllResponses as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); @@ -269,7 +269,7 @@ describe("StartTso start", () => { }); it("should throw an error if session parameter is undefined", async () => { - (StartTso.startCommon as any) = jest.fn((): Promise => { + (StartTso.startCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); @@ -318,14 +318,14 @@ describe("StartTso start", () => { it("should succeed even if z/OSMF parameters are undefined, it will use default parameters", async () => { let error: ImperativeError; let response: IStartStopResponse; - (StartTso.startCommon as any) = jest.fn((): Promise => { + (StartTso.startCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); }); }); }); - (SendTso.getAllResponses as any) = jest.fn((): Promise => { + (SendTso.getAllResponses as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(ZOSMF_RESPONSE); diff --git a/packages/zostso/__tests__/__unit__/StopTso.unit.test.ts b/packages/zostso/__tests__/__unit__/StopTso.unit.test.ts index 839356e28b..9dfe80b08b 100644 --- a/packages/zostso/__tests__/__unit__/StopTso.unit.test.ts +++ b/packages/zostso/__tests__/__unit__/StopTso.unit.test.ts @@ -127,7 +127,7 @@ describe("StopTso getResources", () => { describe("StopTso stopCommon", () => { it("should succeed with correct parameters", async () => { - (ZosmfRestClient.deleteExpectJSON as any) = jest.fn((): Promise => { + (ZosmfRestClient.deleteExpectJSON as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -192,7 +192,7 @@ describe("StopTso stopCommon", () => { describe("StopTso stop", () => { it("should succeed with all correctly provided parameters", async () => { - (StopTso.stopCommon as any) = jest.fn((): Promise => { + (StopTso.stopCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_ZOSMF_RESPONSE); @@ -261,7 +261,7 @@ describe("StopTso stop", () => { }); it("should throw an error if servlet key is inactive", async () => { - (StopTso.stopCommon as any) = jest.fn((): Promise => { + (StopTso.stopCommon as any) = jest.fn((): Promise => { return new Promise((resolve) => { process.nextTick(() => { resolve(PRETEND_BAD_ZOSMF_RESPONSE);