@@ -244,6 +244,38 @@ describe('bin/node-lambda', () => {
244244 } )
245245 } )
246246 } )
247+
248+ describe ( 'node-lambda run (API Gateway events))' , ( ) => {
249+ const eventObj = {
250+ asyncTest : false ,
251+ callbackWaitsForEmptyEventLoop : true ,
252+ callbackCode : 'callback(null);'
253+ }
254+
255+ it ( '`node-lambda run` exitCode is `0`' , function ( done ) {
256+ _generateEventFile ( eventObj )
257+ const run = spawn ( 'node' , [
258+ nodeLambdaPath , 'run' ,
259+ '--handler' , 'index.handler' ,
260+ '--eventFile' , 'event.json' ,
261+ '--apiGateway'
262+ ] )
263+ let stdoutString = ''
264+ run . stdout . on ( 'data' , ( data ) => {
265+ stdoutString += data . toString ( ) . replace ( / \r | \n | \s / g, '' )
266+ } )
267+
268+ run . on ( 'exit' , ( code ) => {
269+ const expected = '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!EmulateonlythebodyoftheAPIGatewayevent.' +
270+ '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Runningindex.handler==================================event' +
271+ '{body:\'{"asyncTest":false,"callbackWaitsForEmptyEventLoop":true,"callbackCode":"callback(null);"}\'}' +
272+ '==================================Stoppingindex.handlerSuccess:'
273+ assert . equal ( stdoutString , expected )
274+ assert . equal ( code , 0 )
275+ done ( )
276+ } )
277+ } )
278+ } )
247279 } )
248280
249281 describe ( 'node-lambda duplicate check of short option' , ( ) => {
0 commit comments