Skip to content

Commit

Permalink
Merge pull request #181 from zowe/bracketing
Browse files Browse the repository at this point in the history
Change criteria bracketing behaviour
  • Loading branch information
AndrewTwydell authored Dec 19, 2024
2 parents 8915c56 + b9df585 commit 3786293
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 4 additions & 0 deletions packages/sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the IBM® CICS® Plug-in for Zowe CLI will be documented in this file.

## Recent Changes

- BugFix: Change getResource criteria bracketing behaviour. [#180](https://github.com/zowe/cics-for-zowe-client/issues/180)

## `6.2.0`

- Enhancement: Add optional query parameters on getResource SDK method. [#168](https://github.com/zowe/cics-for-zowe-client/issues/168)
Expand Down
9 changes: 7 additions & 2 deletions packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,12 @@ describe('Utils - enforceParentheses', () => {

it("should add first bracket when end exists", () => {
const output = Utils.enforceParentheses("input with spaces)");
expect(output).toEqual("(input with spaces)");
expect(output).toEqual("(input with spaces))");
});

it("should add last bracket when first exists", () => {
const output = Utils.enforceParentheses("(input with spec1@| characters");
expect(output).toEqual("(input with spec1@| characters)");
expect(output).toEqual("(input with spec1@| characters");
});

it("should do nothing when both brackets exist", () => {
Expand All @@ -415,6 +415,11 @@ describe('Utils - enforceParentheses', () => {
const output = Utils.enforceParentheses("((()))");
expect(output).toEqual("((()))");
});

it("should add appropriate brackets", () => {
const output = Utils.enforceParentheses("NOT (PROGRAM=CEE* OR PROGRAM=DFH* OR PROGRAM=CJ* OR PROGRAM=EYU* OR PROGRAM=CSQ* OR PROGRAM=CEL* OR PROGRAM=IGZ*)");
expect(output).toEqual("(NOT (PROGRAM=CEE* OR PROGRAM=DFH* OR PROGRAM=CJ* OR PROGRAM=EYU* OR PROGRAM=CSQ* OR PROGRAM=CEL* OR PROGRAM=IGZ*))");
});
});

describe("Utils - getCacheUri", () => {
Expand Down
9 changes: 1 addition & 8 deletions packages/sdk/src/utils/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ export class Utils {
}

public static enforceParentheses(input: string): string {
if (!input.startsWith('(') && !input.endsWith(')')) {
return `(${input})`;
} else if (input.startsWith('(') && !input.endsWith(')')) {
return `${input})`;
} else if (!input.startsWith('(') && input.endsWith(')')) {
return `(${input}`;
}
return input;
return input.startsWith("(") ? input : `(${input})`;
}
}

0 comments on commit 3786293

Please sign in to comment.