@@ -27,7 +27,7 @@ import {
2727
2828import { HEADERS , StateMachineFunctionResponseBody , TIMEOUT_RESPONSE } from "../src/responses"
2929import "./toMatchJsonLogMessage"
30- import { EXPECTED_TRACE_IDS } from "./utils"
30+ import { EXPECTED_TRACE_IDS , getServiceSearchEndpoint , SERVICE_SEARCH_PARAMS } from "./utils"
3131import { LogLevel } from "@aws-lambda-powertools/logger/types"
3232import { createSpineClient } from "@NHSDigital/eps-spine-client"
3333import { MiddyfiedHandler } from "@middy/core"
@@ -355,14 +355,6 @@ describe("Unit tests for app handler including service search", function () {
355355 let testEnv : ReturnType < typeof setupTestEnvironment >
356356 let mockedConfig : MockedPfPConfig
357357
358- const queryParams = {
359- "api-version" : 2 ,
360- searchFields : "ODSCode" ,
361- $filter : "OrganisationTypeId eq 'PHA' and OrganisationSubType eq 'DistanceSelling'" ,
362- $select : "URL,OrganisationSubType" ,
363- $top : 1
364- }
365-
366358 beforeEach ( ( ) => {
367359 testEnv = setupTestEnvironment ( )
368360 mockedConfig = createMockedPfPConfig ( [ TC008_NHS_NUMBER ] )
@@ -394,11 +386,11 @@ describe("Unit tests for app handler including service search", function () {
394386 const event : GetMyPrescriptionsEvent = JSON . parse ( exampleStateMachineEvent )
395387
396388 mock
397- . onGet ( "https://service-search/service-search" , { params : { ...queryParams , search : "flm49" } } )
389+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "flm49" } } )
398390 . reply ( 200 , JSON . parse ( pharmacy2uResponse ) )
399391
400392 mock
401- . onGet ( "https://service-search/service-search" , { params : { ...queryParams , search : "few08" } } )
393+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "few08" } } )
402394 . reply ( 200 , JSON . parse ( pharmicaResponse ) )
403395
404396 mock . onGet ( "https://spine/mm/patientfacingprescriptions" ) . reply ( 200 , JSON . parse ( exampleInteractionResponse ) )
@@ -434,11 +426,11 @@ describe("Unit tests for app handler including service search", function () {
434426 mock . onGet ( "https://spine/mm/patientfacingprescriptions" ) . reply ( 200 , interactionResponse )
435427
436428 mock
437- . onGet ( "https://service-search/service-search" , { params : { ...queryParams , search : "flm49" } } )
429+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "flm49" } } )
438430 . reply ( 200 , JSON . parse ( pharmacy2uResponse ) )
439431
440432 mock
441- . onGet ( "https://service-search/service-search" , { params : { ...queryParams , search : "few08" } } )
433+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "few08" } } )
442434 . reply ( 200 , JSON . parse ( pharmicaResponse ) )
443435
444436 const event : GetMyPrescriptionsEvent = JSON . parse ( exampleStateMachineEvent )
@@ -465,7 +457,7 @@ describe("Unit tests for app handler including service search", function () {
465457 mock . onGet ( "https://spine/mm/patientfacingprescriptions" ) . reply ( 200 , exampleResponse )
466458
467459 // eslint-disable-next-line @typescript-eslint/no-unused-vars
468- mock . onGet ( "https://service-search/service-search" ) . reply ( function ( config ) {
460+ mock . onGet ( getServiceSearchEndpoint ( ) ) . reply ( function ( config ) {
469461 return new Promise ( ( resolve ) => setTimeout ( ( ) => resolve ( [ 200 , { } ] ) , 15_000 ) )
470462 } )
471463
@@ -502,14 +494,6 @@ describe("Unit tests for logging functionality", function () {
502494 let testEnv : ReturnType < typeof setupTestEnvironment >
503495 let mockedConfig : MockedPfPConfig
504496
505- const queryParams = {
506- "api-version" : 2 ,
507- searchFields : "ODSCode" ,
508- $filter : "OrganisationTypeId eq 'PHA' and OrganisationSubType eq 'DistanceSelling'" ,
509- $select : "URL,OrganisationSubType" ,
510- $top : 1
511- }
512-
513497 beforeEach ( ( ) => {
514498 testEnv = setupTestEnvironment ( )
515499 mockedConfig = createMockedPfPConfig ( [ TC008_NHS_NUMBER ] )
@@ -590,11 +574,11 @@ describe("Unit tests for logging functionality", function () {
590574 mock . onGet ( "https://spine/mm/patientfacingprescriptions" ) . reply ( 200 , interactionResponse )
591575
592576 mock
593- . onGet ( "https://service-search/service-search" , { params : { ...queryParams , search : "flm49" } } )
577+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "flm49" } } )
594578 . reply ( 200 , JSON . parse ( pharmacy2uResponse ) )
595579
596580 mock
597- . onGet ( "https://service-search/service-search" , { params : { ...queryParams , search : "few08" } } )
581+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "few08" } } )
598582 . reply ( 200 , JSON . parse ( pharmicaResponse ) )
599583
600584 const event : GetMyPrescriptionsEvent = JSON . parse ( exampleStateMachineEvent )
0 commit comments