@@ -57,7 +57,7 @@ describe('postMI API Handler', () => {
5757 const event = makeApiGwEvent ( {
5858 path : '/mi' ,
5959 body : requestBody ,
60- headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' }
60+ headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' , 'x-request-id' : 'requestId' }
6161 } ) ;
6262
6363 mockedPostMIOperation . mockResolvedValue ( postMIResponse ) ;
@@ -80,7 +80,7 @@ describe('postMI API Handler', () => {
8080 const event = makeApiGwEvent ( {
8181 path : '/mi' ,
8282 body : JSON . stringify ( modifiedRequest ) ,
83- headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' }
83+ headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' , 'x-request-id' : 'requestId' }
8484 } ) ;
8585
8686 const postMI = createPostMIHandler ( mockedDeps ) ;
@@ -94,7 +94,7 @@ describe('postMI API Handler', () => {
9494 it ( 'returns 400 Bad Request when there is no body' , async ( ) => {
9595 const event = makeApiGwEvent ( {
9696 path : '/mi' ,
97- headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' }
97+ headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' , 'x-request-id' : 'requestId' }
9898 } ) ;
9999
100100 const postMI = createPostMIHandler ( mockedDeps ) ;
@@ -111,7 +111,7 @@ describe('postMI API Handler', () => {
111111 path : '/mi' ,
112112 body : requestBody ,
113113 pathParameters : { id : 'id1' } ,
114- headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' }
114+ headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' , 'x-request-id' : 'requestId' }
115115 } ) ;
116116 mockedPostMIOperation . mockRejectedValue ( new Error ( ) ) ;
117117
@@ -123,26 +123,26 @@ describe('postMI API Handler', () => {
123123 } ) ) ;
124124 } ) ;
125125
126- it ( 'returns 400 Bad Request when supplier id is missing' , async ( ) => {
126+ it ( 'returns 500 Bad Request when supplier id is missing' , async ( ) => {
127127 const event = makeApiGwEvent ( {
128128 path : '/mi' ,
129129 body : requestBody ,
130- headers : { 'nhsd-correlation-id' : 'correlationId' }
130+ headers : { 'nhsd-correlation-id' : 'correlationId' , 'x-request-id' : 'requestId' }
131131 } ) ;
132132
133133 const postMI = createPostMIHandler ( mockedDeps ) ;
134134 const result = await postMI ( event , mockDeep < Context > ( ) , jest . fn ( ) ) ;
135135
136136 expect ( result ) . toEqual ( expect . objectContaining ( {
137- statusCode : 400
137+ statusCode : 500
138138 } ) ) ;
139139 } ) ;
140140
141141 it ( 'returns 500 Internal Server Error when correlation id is missing' , async ( ) => {
142142 const event = makeApiGwEvent ( {
143143 path : '/mi' ,
144144 body : requestBody ,
145- headers : { 'nhsd-supplier-id' : 'supplier1' }
145+ headers : { 'nhsd-supplier-id' : 'supplier1' , 'x-request-id' : 'requestId' }
146146 } ) ;
147147
148148 const postMI = createPostMIHandler ( mockedDeps ) ;
@@ -157,7 +157,7 @@ describe('postMI API Handler', () => {
157157 const event = makeApiGwEvent ( {
158158 path : '/mi' ,
159159 body : '{"test": "test"}' ,
160- headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' }
160+ headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' , 'x-request-id' : 'requestId' }
161161 } ) ;
162162
163163 const postMI = createPostMIHandler ( mockedDeps ) ;
@@ -172,7 +172,7 @@ describe('postMI API Handler', () => {
172172 const event = makeApiGwEvent ( {
173173 path : '/mi' ,
174174 body : '{#invalidJSON' ,
175- headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' }
175+ headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' , 'x-request-id' : 'requestId' }
176176 } ) ;
177177
178178 const postMI = createPostMIHandler ( mockedDeps ) ;
@@ -187,7 +187,7 @@ describe('postMI API Handler', () => {
187187 const event = makeApiGwEvent ( {
188188 path : '/mi' ,
189189 body : requestBody ,
190- headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' }
190+ headers : { 'nhsd-supplier-id' : 'supplier1' , 'nhsd-correlation-id' : 'correlationId' , 'x-request-id' : 'requestId' }
191191 } ) ;
192192 const spy = jest . spyOn ( JSON , 'parse' ) . mockImplementation ( ( ) => {
193193 throw 'Unexpected error' ;
0 commit comments