Last active
June 11, 2019 18:09
-
-
Save richardhyatt/2d1ce5845c1b5aec2f31a07d0a814077 to your computer and use it in GitHub Desktop.
Unit Testing AWS Lambda Functions in Node.js #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var expect = require( 'chai' ).expect; | |
var LambdaTester = require( 'lambda-tester' ); | |
var myLambda = require( '../index' ); | |
describe( 'myLambda', function() { | |
[ | |
"Richard", | |
"rhyatt" | |
].forEach( function( validName ) { | |
it( `successful invocation: name=${validName}`, function() { | |
return LambdaTester( myLambda.handler ) | |
.event( { name: validName } ) | |
.expectResult( ( result ) => { | |
expect( result.valid ).to.be.true; | |
}); | |
}); | |
}); | |
[ | |
"Fred", | |
undefined | |
].forEach( function( invalidName ) { | |
it( `fail: when name is invalid: name=${invalidName}`, function() { | |
return LambdaTester( myLambda.handler ) | |
.event( { name: invalidName } ) | |
.expectError( ( err ) => { | |
expect( err.message ).to.equal( 'unknown name' ); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment