@@ -79,6 +79,8 @@ describe('application config routes', () => {
7979 getConfig : jest . fn ( ) . mockReturnValue ( configurations ) ,
8080 } ;
8181
82+ const getConfigurationClient = jest . fn ( ) . mockReturnValue ( client ) ;
83+
8284 const request = { } ;
8385
8486 const okResponse = {
@@ -91,7 +93,12 @@ describe('application config routes', () => {
9193
9294 const logger = loggerMock . create ( ) ;
9395
94- const returnedResponse = await handleGetConfig ( client , request , response , logger ) ;
96+ const returnedResponse = await handleGetConfig (
97+ getConfigurationClient ,
98+ request ,
99+ response ,
100+ logger
101+ ) ;
95102
96103 expect ( returnedResponse ) . toBe ( okResponse ) ;
97104
@@ -100,6 +107,8 @@ describe('application config routes', () => {
100107 value : configurations ,
101108 } ,
102109 } ) ;
110+
111+ expect ( getConfigurationClient ) . toBeCalledWith ( request ) ;
103112 } ) ;
104113
105114 it ( 'return error response when client throws error' , async ( ) => {
@@ -111,6 +120,8 @@ describe('application config routes', () => {
111120 } ) ,
112121 } ;
113122
123+ const getConfigurationClient = jest . fn ( ) . mockReturnValue ( client ) ;
124+
114125 const request = { } ;
115126
116127 const response = {
@@ -119,7 +130,12 @@ describe('application config routes', () => {
119130
120131 const logger = loggerMock . create ( ) ;
121132
122- const returnedResponse = await handleGetConfig ( client , request , response , logger ) ;
133+ const returnedResponse = await handleGetConfig (
134+ getConfigurationClient ,
135+ request ,
136+ response ,
137+ logger
138+ ) ;
123139
124140 expect ( returnedResponse ) . toBe ( ERROR_RESPONSE ) ;
125141
@@ -131,6 +147,7 @@ describe('application config routes', () => {
131147 } ) ;
132148
133149 expect ( logger . error ) . toBeCalledWith ( error ) ;
150+ expect ( getConfigurationClient ) . toBeCalledWith ( request ) ;
134151 } ) ;
135152 } ) ;
136153
@@ -140,6 +157,8 @@ describe('application config routes', () => {
140157 getEntityConfig : jest . fn ( ) . mockReturnValue ( ENTITY_VALUE ) ,
141158 } ;
142159
160+ const getConfigurationClient = jest . fn ( ) . mockReturnValue ( client ) ;
161+
143162 const okResponse = {
144163 statusCode : 200 ,
145164 } ;
@@ -156,7 +175,12 @@ describe('application config routes', () => {
156175
157176 const logger = loggerMock . create ( ) ;
158177
159- const returnedResponse = await handleGetEntityConfig ( client , request , response , logger ) ;
178+ const returnedResponse = await handleGetEntityConfig (
179+ getConfigurationClient ,
180+ request ,
181+ response ,
182+ logger
183+ ) ;
160184
161185 expect ( returnedResponse ) . toBe ( okResponse ) ;
162186
@@ -165,6 +189,8 @@ describe('application config routes', () => {
165189 value : ENTITY_VALUE ,
166190 } ,
167191 } ) ;
192+
193+ expect ( getConfigurationClient ) . toBeCalledWith ( request ) ;
168194 } ) ;
169195
170196 it ( 'return error response when client throws error' , async ( ) => {
@@ -176,6 +202,8 @@ describe('application config routes', () => {
176202 } ) ,
177203 } ;
178204
205+ const getConfigurationClient = jest . fn ( ) . mockReturnValue ( client ) ;
206+
179207 const request = {
180208 params : {
181209 entity : ENTITY_NAME ,
@@ -188,7 +216,12 @@ describe('application config routes', () => {
188216
189217 const logger = loggerMock . create ( ) ;
190218
191- const returnedResponse = await handleGetEntityConfig ( client , request , response , logger ) ;
219+ const returnedResponse = await handleGetEntityConfig (
220+ getConfigurationClient ,
221+ request ,
222+ response ,
223+ logger
224+ ) ;
192225
193226 expect ( returnedResponse ) . toBe ( ERROR_RESPONSE ) ;
194227
@@ -200,6 +233,8 @@ describe('application config routes', () => {
200233 } ) ;
201234
202235 expect ( logger . error ) . toBeCalledWith ( error ) ;
236+
237+ expect ( getConfigurationClient ) . toBeCalledWith ( request ) ;
203238 } ) ;
204239 } ) ;
205240
@@ -209,6 +244,8 @@ describe('application config routes', () => {
209244 updateEntityConfig : jest . fn ( ) . mockReturnValue ( ENTITY_NEW_VALUE ) ,
210245 } ;
211246
247+ const getConfigurationClient = jest . fn ( ) . mockReturnValue ( client ) ;
248+
212249 const okResponse = {
213250 statusCode : 200 ,
214251 } ;
@@ -228,7 +265,12 @@ describe('application config routes', () => {
228265
229266 const logger = loggerMock . create ( ) ;
230267
231- const returnedResponse = await handleUpdateEntityConfig ( client , request , response , logger ) ;
268+ const returnedResponse = await handleUpdateEntityConfig (
269+ getConfigurationClient ,
270+ request ,
271+ response ,
272+ logger
273+ ) ;
232274
233275 expect ( returnedResponse ) . toBe ( okResponse ) ;
234276
@@ -241,6 +283,8 @@ describe('application config routes', () => {
241283 } ) ;
242284
243285 expect ( logger . error ) . not . toBeCalled ( ) ;
286+
287+ expect ( getConfigurationClient ) . toBeCalledWith ( request ) ;
244288 } ) ;
245289
246290 it ( 'return error response when client fails' , async ( ) => {
@@ -252,6 +296,8 @@ describe('application config routes', () => {
252296 } ) ,
253297 } ;
254298
299+ const getConfigurationClient = jest . fn ( ) . mockReturnValue ( client ) ;
300+
255301 const request = {
256302 params : {
257303 entity : ENTITY_NAME ,
@@ -267,7 +313,12 @@ describe('application config routes', () => {
267313
268314 const logger = loggerMock . create ( ) ;
269315
270- const returnedResponse = await handleUpdateEntityConfig ( client , request , response , logger ) ;
316+ const returnedResponse = await handleUpdateEntityConfig (
317+ getConfigurationClient ,
318+ request ,
319+ response ,
320+ logger
321+ ) ;
271322
272323 expect ( returnedResponse ) . toBe ( ERROR_RESPONSE ) ;
273324
@@ -279,6 +330,8 @@ describe('application config routes', () => {
279330 } ) ;
280331
281332 expect ( logger . error ) . toBeCalledWith ( error ) ;
333+
334+ expect ( getConfigurationClient ) . toBeCalledWith ( request ) ;
282335 } ) ;
283336 } ) ;
284337
@@ -288,6 +341,8 @@ describe('application config routes', () => {
288341 deleteEntityConfig : jest . fn ( ) . mockReturnValue ( ENTITY_NAME ) ,
289342 } ;
290343
344+ const getConfigurationClient = jest . fn ( ) . mockReturnValue ( client ) ;
345+
291346 const okResponse = {
292347 statusCode : 200 ,
293348 } ;
@@ -304,7 +359,12 @@ describe('application config routes', () => {
304359
305360 const logger = loggerMock . create ( ) ;
306361
307- const returnedResponse = await handleDeleteEntityConfig ( client , request , response , logger ) ;
362+ const returnedResponse = await handleDeleteEntityConfig (
363+ getConfigurationClient ,
364+ request ,
365+ response ,
366+ logger
367+ ) ;
308368
309369 expect ( returnedResponse ) . toBe ( okResponse ) ;
310370
@@ -317,6 +377,7 @@ describe('application config routes', () => {
317377 } ) ;
318378
319379 expect ( logger . error ) . not . toBeCalled ( ) ;
380+ expect ( getConfigurationClient ) . toBeCalledWith ( request ) ;
320381 } ) ;
321382
322383 it ( 'return error response when client fails' , async ( ) => {
@@ -328,6 +389,8 @@ describe('application config routes', () => {
328389 } ) ,
329390 } ;
330391
392+ const getConfigurationClient = jest . fn ( ) . mockReturnValue ( client ) ;
393+
331394 const request = {
332395 params : {
333396 entity : ENTITY_NAME ,
@@ -340,7 +403,12 @@ describe('application config routes', () => {
340403
341404 const logger = loggerMock . create ( ) ;
342405
343- const returnedResponse = await handleDeleteEntityConfig ( client , request , response , logger ) ;
406+ const returnedResponse = await handleDeleteEntityConfig (
407+ getConfigurationClient ,
408+ request ,
409+ response ,
410+ logger
411+ ) ;
344412
345413 expect ( returnedResponse ) . toBe ( ERROR_RESPONSE ) ;
346414
@@ -352,6 +420,8 @@ describe('application config routes', () => {
352420 } ) ;
353421
354422 expect ( logger . error ) . toBeCalledWith ( error ) ;
423+
424+ expect ( getConfigurationClient ) . toBeCalledWith ( request ) ;
355425 } ) ;
356426 } ) ;
357427} ) ;
0 commit comments