@@ -28,10 +28,15 @@ api.get('/', function(req,res) {
28
28
res . status ( 200 ) . json ( { method : 'get' , status : 'ok' } )
29
29
} )
30
30
31
+
31
32
api . get ( '/return' , async function ( req , res ) {
32
33
return { method : 'get' , status : 'ok' }
33
34
} )
34
35
36
+ api . get ( '/returnNoArgs' , async ( ) => {
37
+ return { method : 'get' , status : 'ok' }
38
+ } )
39
+
35
40
api2 . get ( '/' , function ( req , res ) {
36
41
res . status ( 200 ) . json ( { method : 'get' , status : 'ok' } )
37
42
} )
@@ -310,6 +315,18 @@ describe('Route Tests:', function() {
310
315
} ) // end it
311
316
312
317
318
+ it ( 'Simple path w/ async return (no args)' , async function ( ) {
319
+ let _event = Object . assign ( { } , event , { path : '/returnNoArgs' } )
320
+ let result = await new Promise ( r => api . run ( _event , { } , ( e , res ) => { r ( res ) } ) )
321
+ expect ( result ) . to . deep . equal ( {
322
+ multiValueHeaders : { 'content-type' : [ 'application/json' ] } ,
323
+ statusCode : 200 ,
324
+ body : '{"method":"get","status":"ok"}' ,
325
+ isBase64Encoded : false
326
+ } )
327
+ } ) // end it
328
+
329
+
313
330
it ( 'Simple path, no `context`' , async function ( ) {
314
331
let _event = Object . assign ( { } , event , { } )
315
332
let result = await new Promise ( r => api . run ( _event , null , ( e , res ) => { r ( res ) } ) )
@@ -1029,7 +1046,7 @@ describe('Route Tests:', function() {
1029
1046
1030
1047
describe ( 'Configuration errors' , function ( ) {
1031
1048
1032
- it ( 'Missing handler' , async function ( ) {
1049
+ it ( 'Missing handler (w/ route) ' , async function ( ) {
1033
1050
let error
1034
1051
try {
1035
1052
const api_error1 = require ( '../index' ) ( { version : 'v1.0' } )
@@ -1042,8 +1059,7 @@ describe('Route Tests:', function() {
1042
1059
expect ( error . message ) . to . equal ( 'No handler or middleware specified for GET method on /test-missing-handler route.' )
1043
1060
} ) // end it
1044
1061
1045
- // TODO: ???
1046
- it ( 'Missing callback' , async function ( ) {
1062
+ it ( 'Missing handler' , async function ( ) {
1047
1063
let error
1048
1064
try {
1049
1065
const api_error1 = require ( '../index' ) ( { version : 'v1.0' } )
0 commit comments