@@ -11,7 +11,7 @@ describe('API Lambda handler', () => {
1111 it ( 'passes if S3 and DynamoDB are available' , async ( ) => {
1212
1313 const event = makeApiGwEvent ( { path : '/_status' ,
14- headers : { 'nhsd-supplier-id ' : 'supplier1' , 'nhsd-correlation-id' : ' correlationId' , 'x-request-id' : 'requestId '}
14+ headers : { 'Nhsd-Correlation-Id ' : 'correlationId' }
1515 } ) ;
1616
1717 const getLetterDataHandler = createGetStatusHandler ( getMockedDeps ( ) ) ;
@@ -28,15 +28,14 @@ describe('API Lambda handler', () => {
2828 mockedDeps . s3Client . send = jest . fn ( ) . mockRejectedValue ( new Error ( 'unexpected error' ) ) ;
2929
3030 const event = makeApiGwEvent ( { path : '/_status' ,
31- headers : { 'nhsd-supplier-id ' : 'supplier1' , 'nhsd-correlation-id' : ' correlationId' , 'x-request-id' : 'requestId '}
31+ headers : { 'Nhsd-Correlation-Id ' : 'correlationId' }
3232 } ) ;
3333
3434 const getLetterDataHandler = createGetStatusHandler ( mockedDeps ) ;
3535 const result = await getLetterDataHandler ( event , mockDeep < Context > ( ) , jest . fn ( ) ) ;
3636
37- expect ( result ) . toEqual ( expect . objectContaining ( {
38- statusCode : 500
39- } ) ) ;
37+ expect ( result ! . statusCode ) . toBe ( 500 ) ;
38+ expect ( JSON . parse ( result ! . body ) . errors [ 0 ] . id ) . toBe ( 'correlationId' ) ;
4039 } ) ;
4140
4241
@@ -45,28 +44,29 @@ describe('API Lambda handler', () => {
4544 mockedDeps . dbHealthcheck . check = jest . fn ( ) . mockRejectedValue ( new Error ( 'unexpected error' ) ) ;
4645
4746 const event = makeApiGwEvent ( { path : '/_status' ,
48- headers : { 'nhsd-supplier-id ' : 'supplier1' , 'nhsd-correlation-id' : ' correlationId' , 'x-request-id' : 'requestId '}
47+ headers : { 'Nhsd-Correlation-Id ' : 'correlationId' }
4948 } ) ;
5049
5150 const getLetterDataHandler = createGetStatusHandler ( mockedDeps ) ;
5251 const result = await getLetterDataHandler ( event , mockDeep < Context > ( ) , jest . fn ( ) ) ;
5352
54- expect ( result ) . toEqual ( expect . objectContaining ( {
55- statusCode : 500
56- } ) ) ;
53+ expect ( result ! . statusCode ) . toBe ( 500 ) ;
54+ expect ( JSON . parse ( result ! . body ) . errors [ 0 ] . id ) . toBe ( 'correlationId' ) ;
5755 } ) ;
5856
59- it ( 'fails if request ID is absent' , async ( ) => {
57+ it ( 'allows the correlation ID to be absent' , async ( ) => {
58+ const mockedDeps = getMockedDeps ( ) ;
59+ mockedDeps . dbHealthcheck . check = jest . fn ( ) . mockRejectedValue ( new Error ( 'unexpected error' ) ) ;
60+
6061 const event = makeApiGwEvent ( { path : '/_status' ,
61- headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' }
62+ headers : { }
6263 } ) ;
6364
64- const getLetterDataHandler = createGetStatusHandler ( getMockedDeps ( ) ) ;
65+ const getLetterDataHandler = createGetStatusHandler ( mockedDeps ) ;
6566 const result = await getLetterDataHandler ( event , mockDeep < Context > ( ) , jest . fn ( ) ) ;
6667
67- expect ( result ) . toEqual ( expect . objectContaining ( {
68- statusCode : 500
69- } ) ) ;
68+ expect ( result ! . statusCode ) . toBe ( 500 ) ;
69+ expect ( JSON . parse ( result ! . body ) . errors [ 0 ] . id ) . toBeDefined ( ) ;
7070 } ) ;
7171
7272 function getMockedDeps ( ) : jest . Mocked < Deps > {
0 commit comments