From 4119864a35c313670d4d34d82285818d45de8a0e Mon Sep 17 00:00:00 2001 From: Quan HL Date: Thu, 27 Jul 2023 21:07:44 +0700 Subject: [PATCH] fix customerdata should not be snakeCase --- lib/utils/http-requestor.js | 2 +- test/create-call-test.js | 14 +++++++++++++- test/index.js | 28 ++++++++++++++-------------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/lib/utils/http-requestor.js b/lib/utils/http-requestor.js index fba6aade..ce7a5916 100644 --- a/lib/utils/http-requestor.js +++ b/lib/utils/http-requestor.js @@ -87,7 +87,7 @@ class HttpRequestor extends BaseRequestor { assert(HookMsgTypes.includes(type)); - const payload = params ? snakeCaseKeys(params, ['customerData', 'sip']) : null; + const payload = params ? snakeCaseKeys(params, ['sip']) : null; const url = hook.url || hook; const method = hook.method || 'POST'; let buf = ''; diff --git a/test/create-call-test.js b/test/create-call-test.js index 44b61b23..a6d7a6b8 100644 --- a/test/create-call-test.js +++ b/test/create-call-test.js @@ -80,6 +80,15 @@ test('test create-call call-hook basic authentication', async(t) => { "username": "username", "password": "password" }, + "tag": { + "callCount": 10, + "env": "DEVELOPMENT", + "processId": "processId", + "Customer": "Customer", + "Vehicle": "Vehicle", + "Event_Camel": "Event_Camel", + "CamelCase": "CamelCase" + }, "from": from, "to": { "type": "phone", @@ -96,9 +105,12 @@ test('test create-call call-hook basic authentication', async(t) => { //THEN await p; - let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}`) + let obj = await getJSON(`http:127.0.0.1:3100/lastRequest/${from}`); + console.log(obj); t.ok(obj.headers.Authorization = 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=', 'create-call: call-hook contains basic authentication header'); + t.ok(obj.body.customerdata.callCount = 10, + 'create-call: call-hook contains correct format for customerData'); disconnect(); } catch (err) { console.log(`error received: ${err}`); diff --git a/test/index.js b/test/index.js index 033f6c8b..e12f5c0f 100644 --- a/test/index.js +++ b/test/index.js @@ -1,19 +1,19 @@ -require('./ws-requestor-unit-test'); -require('./unit-tests'); +// require('./ws-requestor-unit-test'); +// require('./unit-tests'); require('./docker_start'); require('./create-test-db'); -require('./account-validation-tests'); -require('./dial-tests'); -require('./webhooks-tests'); -require('./say-tests'); -require('./gather-tests'); -require('./transcribe-tests'); -require('./sip-request-tests'); +// require('./account-validation-tests'); +// require('./dial-tests'); +// require('./webhooks-tests'); +// require('./say-tests'); +// require('./gather-tests'); +// require('./transcribe-tests'); +// require('./sip-request-tests'); require('./create-call-test'); -require('./play-tests'); -require('./sip-refer-tests'); -require('./listen-tests'); -require('./config-test'); -require('./queue-test'); +// require('./play-tests'); +// require('./sip-refer-tests'); +// require('./listen-tests'); +// require('./config-test'); +// require('./queue-test'); require('./remove-test-db'); require('./docker_stop'); \ No newline at end of file