diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 3b0b7b65..018a2feb 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -18,7 +18,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v1 with: - node-version: '10.x' + node-version: '12.x' - run: npm install - run: npm link - run: npm run integration-test diff --git a/lib/commands/smapi/smapi-command-handler.js b/lib/commands/smapi/smapi-command-handler.js index 87e6b581..600f93de 100644 --- a/lib/commands/smapi/smapi-command-handler.js +++ b/lib/commands/smapi/smapi-command-handler.js @@ -110,17 +110,20 @@ const smapiCommandHandler = (swaggerApiOperationName, flatParamsMap, commanderTo const beforeSendProcessor = new BeforeSendProcessor(inputCmdObj._name, paramsObject, modelIntrospector, profile); beforeSendProcessor.processAll(); - // TODO revisit with debug flow + const functionName = _sdkFunctionName(swaggerApiOperationName); + const params = getParamNames(client[functionName]); + const args = _mapToArgs(params, paramsObject); + if (inputOpts.debug) { + const payload = {}; + params.forEach((k, i) => { + payload[k] = args[i]; + }); Messenger.getInstance().info(`Operation: ${swaggerApiOperationName}`); Messenger.getInstance().info('Payload:'); - Messenger.getInstance().info(`${jsonView.toString(paramsObject)}\n`); + Messenger.getInstance().info(`${jsonView.toString(payload)}\n`); } - const functionName = _sdkFunctionName(swaggerApiOperationName); - const params = getParamNames(client[functionName]); - const args = _mapToArgs(params, paramsObject); - return client[functionName](...args) .then(response => { const { body, headers, statusCode } = response; diff --git a/lib/utils/string-utils.js b/lib/utils/string-utils.js index 14d5a0ef..262956a8 100644 --- a/lib/utils/string-utils.js +++ b/lib/utils/string-utils.js @@ -39,7 +39,7 @@ function kebabCase(str) { } function standardize(str) { - return camelCase(str).toLowerCase(); + return filterNonAlphanumeric(camelCase(str).toLowerCase()); } function isNonEmptyString(str) { return R.is(String, str) && !R.isEmpty(str); diff --git a/test/unit/commands/smapi/smapi-command-handler-test.js b/test/unit/commands/smapi/smapi-command-handler-test.js index a1775b8f..4b5099d1 100644 --- a/test/unit/commands/smapi/smapi-command-handler-test.js +++ b/test/unit/commands/smapi/smapi-command-handler-test.js @@ -116,7 +116,12 @@ describe('Smapi test - smapiCommandHandler function', () => { expect(messengerStub.args[0]).eql(['INFO', 'Operation: someApiOperation']); expect(messengerStub.args[1]).eql(['INFO', 'Payload:']); - expect(messengerStub.args[2]).eql(['INFO', `${jsonView.toString({ skillId })}\n`]); + expect(messengerStub.args[2]) + .eql(['INFO', `${jsonView.toString({ someJson: null, + skillId, + someNonPopulatedProperty: null, + someArray: null, + simulationsApiRequest: null })}\n`]); expect(messengerStub.args[3]).eql(['INFO', `Status code: ${fakeResponse.statusCode}`]); expect(messengerStub.args[4]).eql(['INFO', `Response headers: ${jsonView.toString(fakeResponse.headers)}`]); expect(messengerStub.args[5]).eql(['INFO', `Response body: ${jsonView.toString(fakeResponse.body)}`]); diff --git a/test/unit/utils/string-utils-test.js b/test/unit/utils/string-utils-test.js index ebb7889b..5495cfbe 100644 --- a/test/unit/utils/string-utils-test.js +++ b/test/unit/utils/string-utils-test.js @@ -45,6 +45,33 @@ describe('Utils test - string utility', () => { }); }); + describe('# test function standardize', () => { + [ + { + testCase: 'camel case to lower', + str: 'testTest', + expectation: 'testtest' + }, + { + testCase: 'capital case to lower', + str: 'TestTest', + expectation: 'testtest' + }, + { + testCase: 'non alphanumeric', + str: 'test.test', + expectation: 'testtest' + }, + ].forEach(({ testCase, str, expectation }) => { + it(`| ${testCase}, expect standardize ${str}`, () => { + // call + const callResult = stringUtils.standardize(str); + // verify + expect(callResult).equal(expectation); + }); + }); + }); + describe('# test function isNonBlankString', () => { [ {