From b9df58574bbede2f6c6208de2d0b5e1bb9f7aa9b Mon Sep 17 00:00:00 2001 From: Andrew Twydell Date: Thu, 19 Dec 2024 10:27:12 +0000 Subject: [PATCH] change criteria bracketing behaviour Signed-off-by: Andrew Twydell --- packages/sdk/CHANGELOG.md | 4 ++++ packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts | 9 +++++++-- packages/sdk/src/utils/Utils.ts | 9 +-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md index a0e3091..0e4ffa7 100644 --- a/packages/sdk/CHANGELOG.md +++ b/packages/sdk/CHANGELOG.md @@ -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) diff --git a/packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts b/packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts index d615c19..07e7fcd 100644 --- a/packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts +++ b/packages/sdk/__tests__/__unit__/utils/Utils.unit.test.ts @@ -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", () => { @@ -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", () => { diff --git a/packages/sdk/src/utils/Utils.ts b/packages/sdk/src/utils/Utils.ts index df6ad2a..98c45ce 100644 --- a/packages/sdk/src/utils/Utils.ts +++ b/packages/sdk/src/utils/Utils.ts @@ -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})`; } }