Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change criteria bracketing behaviour #181

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested this yet, but it doesn't seem like having an extra closing ) will work in some scenarios 🤔

});

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})`;
}
}
Loading