@@ -64,6 +64,9 @@ describe('serve', () => {
6464 id : 'testFuncId' ,
6565 handlerFunc : testHandlerFunc ,
6666 } ;
67+ const testHttpEvent = {
68+ integration : 'lambda'
69+ }
6770 const testReq = {
6871 method : 'testmethod' ,
6972 headers : 'testheaders' ,
@@ -76,7 +79,7 @@ describe('serve', () => {
7679 } ;
7780 testRes . status = sinon . stub ( ) . returns ( testRes ) ;
7881 module . getContext = sinon . stub ( ) . returns ( 'testContext' ) ;
79- const handler = module . _handlerBase ( testFuncConf ) ;
82+ const handler = module . _handlerBase ( testFuncConf , testHttpEvent ) ;
8083 handler ( testReq , testRes ) ;
8184 expect ( testRes . status ) . to . have . been . calledWith ( 200 ) ;
8285 expect ( testRes . send ) . to . have . been . calledWith ( testHandlerResp ) ;
@@ -111,6 +114,44 @@ describe('serve', () => {
111114 expect ( testRes . status ) . to . have . been . calledWith ( 500 ) ;
112115 expect ( testRes . send ) . to . have . been . calledWith ( testHandlerErr ) ;
113116 } ) ;
117+
118+ it ( 'handles lambda-proxy integration for request and response' , ( ) => {
119+ const testHandlerResp = { statusCode : 200 , body : 'testHandlerResp' } ;
120+ const testHandlerFunc = sinon . spy ( ( ev , ct , cb ) => {
121+ cb ( null , testHandlerResp ) ;
122+ } ) ;
123+ const testFuncConf = {
124+ id : 'testFuncId' ,
125+ handlerFunc : testHandlerFunc ,
126+ } ;
127+ const testHttpEvent = { }
128+ const testReq = {
129+ method : 'testmethod' ,
130+ headers : 'testheaders' ,
131+ body : 'testbody' ,
132+ params : 'testparams' ,
133+ query : 'testquery' ,
134+ } ;
135+ const testRes = {
136+ send : sinon . spy ( ) ,
137+ } ;
138+ testRes . status = sinon . stub ( ) . returns ( testRes ) ;
139+ module . getContext = sinon . stub ( ) . returns ( 'testContext' ) ;
140+ const handler = module . _handlerBase ( testFuncConf , testHttpEvent ) ;
141+ handler ( testReq , testRes ) ;
142+ expect ( testRes . status ) . to . have . been . calledWith ( testHandlerResp . statusCode ) ;
143+ expect ( testRes . send ) . to . have . been . calledWith ( testHandlerResp . body ) ;
144+ expect ( testHandlerFunc ) . to . have . been . calledWith (
145+ {
146+ body : 'testbody' ,
147+ headers : 'testheaders' ,
148+ method : 'testmethod' ,
149+ path : 'testparams' ,
150+ queryStringParameters : 'testquery' ,
151+ } ,
152+ 'testContext'
153+ ) ;
154+ } ) ;
114155 } ) ;
115156
116157 describe ( '_optionsHandler' , ( ) => {
0 commit comments