Skip to content

Commit

Permalink
Merge pull request #2392 from COBOL-Erik/patch-1
Browse files Browse the repository at this point in the history
Always treat encoding as a string for encoding.trim()
  • Loading branch information
traeok authored Dec 24, 2024
2 parents aa2d6e6 + 8c9369c commit 0d3f6a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/zosjobs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

All notable changes to the Zowe z/OS jobs SDK package will be documented in this file.

## Recent Changes

- BugFix: Check if encoding is set and not empty now works for numeric-only value in encoding (GetJobs.ts). [#2392] (https://github.com/zowe/zowe-cli/pull/2392).

## `8.7.1`

- BugFix: Fixed an error where the Delete Jobs API response was not returned if the `modifyVersion` parameter was not specified, even though it was available. [#2352](https://github.com/zowe/zowe-cli/pull/2352)

## `8.7.0`

- Enhancement: Added waitForOutput & waitForActive as optional parameters to download on zosjobs. [#2326] (https://github.com/zowe/zowe-cli/pull/2326).

## `8.5.0`
Expand Down
7 changes: 7 additions & 0 deletions packages/zosjobs/__tests__/__unit__/GetJobs.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,13 @@ describe("GetJobs tests", () => {
expect(content).toEqual(GetJobsData.SAMPLE_JES_MSG_LG);
});

it("should return spool content from getSpoolContentById with encoding as a number if z/OSMF response is mocked", async () => {
(ZosmfRestClient.getExpectString as any) = mockGetJobsStringData(GetJobsData.SAMPLE_JES_MSG_LG);
const content = await GetJobs.getSpoolContentById(pretendSession, "MYJOB1", "JOB0123", 1, 278 as any);
expect((ZosmfRestClient.getExpectString as any).mock.calls[0][1]).toContain("fileEncoding=278");
expect(content).toEqual(GetJobsData.SAMPLE_JES_MSG_LG);
});

it("should error if spoolID is omitted from getSpoolContentById", async () => {
let err: Error;
try {
Expand Down
4 changes: 3 additions & 1 deletion packages/zosjobs/src/GetJobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ export class GetJobs {
ImperativeExpect.toNotBeNullOrUndefined(spoolId, "Required parameter spoolId must be defined");
let parameters: string = "/" + encodeURIComponent(jobname) + "/" + encodeURIComponent(jobid) +
JobsConstants.RESOURCE_SPOOL_FILES + "/" + encodeURIComponent(spoolId) + JobsConstants.RESOURCE_SPOOL_CONTENT;
if (encoding && encoding.trim() != "") {parameters += "?fileEncoding=" + encoding;}
if (encoding != null && String(encoding).trim() !== "") {
parameters += "?fileEncoding=" + encoding;
}
Logger.getAppLogger().info("GetJobs.getSpoolContentById() parameters: " + parameters);
return ZosmfRestClient.getExpectString(session, JobsConstants.RESOURCE + parameters, [Headers.TEXT_PLAIN_UTF8]);
}
Expand Down

0 comments on commit 0d3f6a9

Please sign in to comment.