11import { APIGatewayProxyResult as LambdaResult , Context } from "aws-lambda"
2- import {
3- DEFAULT_HANDLER_PARAMS ,
4- newHandler ,
5- GetMyPrescriptionsEvent ,
6- stateMachineEventHandler ,
7- STATE_MACHINE_MIDDLEWARE
8- } from "../src/getMyPrescriptions"
92import { Logger } from "@aws-lambda-powertools/logger"
3+ import { LogLevel } from "@aws-lambda-powertools/logger/types"
104import axios from "axios"
115import MockAdapter from "axios-mock-adapter"
126import {
@@ -15,23 +9,35 @@ import {
159 it ,
1610 jest
1711} from "@jest/globals"
12+ import { createSpineClient } from "@NHSDigital/eps-spine-client"
13+ import { MiddyfiedHandler } from "@middy/core"
1814
1915import {
16+ createMockedPfPConfig ,
2017 mockAPIResponseBody as mockResponseBody ,
2118 mockInteractionResponseBody ,
2219 mockPharmacy2uResponse ,
2320 mockPharmicaResponse ,
2421 helloworldContext ,
25- mockStateMachineInputEvent
22+ mockStateMachineInputEvent ,
23+ MockedPfPConfig ,
24+ setupTestEnvironment
2625} from "@pfp-common/testing"
26+ import {
27+ SERVICE_SEARCH_BASE_QUERY_PARAMS ,
28+ getServiceSearchEndpoint
29+ } from "@prescriptionsforpatients/serviceSearchClient"
2730
31+ import {
32+ DEFAULT_HANDLER_PARAMS ,
33+ newHandler ,
34+ GetMyPrescriptionsEvent ,
35+ stateMachineEventHandler ,
36+ STATE_MACHINE_MIDDLEWARE
37+ } from "../src/getMyPrescriptions"
2838import { HEADERS , StateMachineFunctionResponseBody , TIMEOUT_RESPONSE } from "../src/responses"
2939import "./toMatchJsonLogMessage"
30- import { EXPECTED_TRACE_IDS , getServiceSearchEndpoint , SERVICE_SEARCH_PARAMS } from "./utils"
31- import { LogLevel } from "@aws-lambda-powertools/logger/types"
32- import { createSpineClient } from "@NHSDigital/eps-spine-client"
33- import { MiddyfiedHandler } from "@middy/core"
34- import { createMockedPfPConfig , MockedPfPConfig , setupTestEnvironment } from "@pfp-common/testing"
40+ import { EXPECTED_TRACE_IDS } from "./utils"
3541
3642const TC008_NHS_NUMBER = "9992387920"
3743
@@ -386,11 +392,11 @@ describe("Unit tests for app handler including service search", function () {
386392 const event : GetMyPrescriptionsEvent = JSON . parse ( exampleStateMachineEvent )
387393
388394 mock
389- . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "flm49" } } )
395+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_BASE_QUERY_PARAMS , search : "flm49" } } )
390396 . reply ( 200 , JSON . parse ( pharmacy2uResponse ) )
391397
392398 mock
393- . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "few08" } } )
399+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_BASE_QUERY_PARAMS , search : "few08" } } )
394400 . reply ( 200 , JSON . parse ( pharmicaResponse ) )
395401
396402 mock . onGet ( "https://spine/mm/patientfacingprescriptions" ) . reply ( 200 , JSON . parse ( exampleInteractionResponse ) )
@@ -426,11 +432,11 @@ describe("Unit tests for app handler including service search", function () {
426432 mock . onGet ( "https://spine/mm/patientfacingprescriptions" ) . reply ( 200 , interactionResponse )
427433
428434 mock
429- . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "flm49" } } )
435+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_BASE_QUERY_PARAMS , search : "flm49" } } )
430436 . reply ( 200 , JSON . parse ( pharmacy2uResponse ) )
431437
432438 mock
433- . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "few08" } } )
439+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_BASE_QUERY_PARAMS , search : "few08" } } )
434440 . reply ( 200 , JSON . parse ( pharmicaResponse ) )
435441
436442 const event : GetMyPrescriptionsEvent = JSON . parse ( exampleStateMachineEvent )
@@ -574,11 +580,11 @@ describe("Unit tests for logging functionality", function () {
574580 mock . onGet ( "https://spine/mm/patientfacingprescriptions" ) . reply ( 200 , interactionResponse )
575581
576582 mock
577- . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "flm49" } } )
583+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_BASE_QUERY_PARAMS , search : "flm49" } } )
578584 . reply ( 200 , JSON . parse ( pharmacy2uResponse ) )
579585
580586 mock
581- . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_PARAMS , search : "few08" } } )
587+ . onGet ( getServiceSearchEndpoint ( ) , { params : { ...SERVICE_SEARCH_BASE_QUERY_PARAMS , search : "few08" } } )
582588 . reply ( 200 , JSON . parse ( pharmicaResponse ) )
583589
584590 const event : GetMyPrescriptionsEvent = JSON . parse ( exampleStateMachineEvent )
0 commit comments