@@ -212,6 +212,40 @@ describe('handler', function() {
212212 } ) ;
213213 } ) ;
214214
215+ it ( 'middleware does not override context and event when their values are null' , function ( ) {
216+ const spy = sinon . spy ( ) ;
217+
218+ const fixture = lambdaHandler ( )
219+ . use ( function ( event , context , next ) {
220+ return next ( null , null , null ) ;
221+ } )
222+ . use ( spy ) ;
223+
224+ return fixture ( testEvent , testContext )
225+ . then ( ( ) => {
226+ expect ( spy . calledOnce ) . to . be . true ;
227+ expect ( spy . firstCall . args [ 0 ] ) . to . equal ( testEvent ) ;
228+ expect ( spy . firstCall . args [ 1 ] ) . to . equal ( testContext ) ;
229+ } ) ;
230+ } ) ;
231+
232+ it ( 'middleware does not override context and event when their values are undefined' , function ( ) {
233+ const spy = sinon . spy ( ) ;
234+
235+ const fixture = lambdaHandler ( )
236+ . use ( function ( event , context , next ) {
237+ return next ( null , undefined , undefined ) ;
238+ } )
239+ . use ( spy ) ;
240+
241+ return fixture ( testEvent , testContext )
242+ . then ( ( ) => {
243+ expect ( spy . calledOnce ) . to . be . true ;
244+ expect ( spy . firstCall . args [ 0 ] ) . to . equal ( testEvent ) ;
245+ expect ( spy . firstCall . args [ 1 ] ) . to . equal ( testContext ) ;
246+ } ) ;
247+ } ) ;
248+
215249 it ( 'middleware can override result after await next()' , function ( ) {
216250 const stub = sinon . stub ( ) . returns ( 'foo' ) ;
217251 const fixture = lambdaHandler ( )
0 commit comments