@@ -35,13 +35,21 @@ api.get('/attachment/png', function(req,res) {
35
35
} )
36
36
37
37
api . get ( '/attachment/csv' , function ( req , res ) {
38
- res . attachment ( '/ test/path/foo.csv' ) . send ( 'filedata' )
38
+ res . attachment ( 'test/path/foo.csv' ) . send ( 'filedata' )
39
39
} )
40
40
41
41
api . get ( '/attachment/custom' , function ( req , res ) {
42
42
res . attachment ( '/test/path/foo.test' ) . send ( 'filedata' )
43
43
} )
44
44
45
+ api . get ( '/attachment/empty-string' , function ( req , res ) {
46
+ res . attachment ( ' ' ) . send ( 'filedata' )
47
+ } )
48
+
49
+ api . get ( '/attachment/null-string' , function ( req , res ) {
50
+ res . attachment ( null ) . send ( 'filedata' )
51
+ } )
52
+
45
53
46
54
/******************************************************************************/
47
55
/*** BEGIN TESTS ***/
@@ -99,4 +107,24 @@ describe('Attachment Tests:', function() {
99
107
} )
100
108
} ) // end it
101
109
110
+ it ( 'Empty string' , function ( ) {
111
+ let _event = Object . assign ( { } , event , { path : '/attachment/empty-string' } )
112
+
113
+ return new Promise ( ( resolve , reject ) => {
114
+ api . run ( _event , { } , function ( err , res ) { resolve ( res ) } )
115
+ } ) . then ( ( result ) => {
116
+ expect ( result ) . to . deep . equal ( { headers : { 'Content-Disposition' : 'attachment' , 'Content-Type' : 'application/json' } , statusCode : 200 , body : 'filedata' , isBase64Encoded : false } )
117
+ } )
118
+ } ) // end it
119
+
120
+ it ( 'Null string' , function ( ) {
121
+ let _event = Object . assign ( { } , event , { path : '/attachment/empty-string' } )
122
+
123
+ return new Promise ( ( resolve , reject ) => {
124
+ api . run ( _event , { } , function ( err , res ) { resolve ( res ) } )
125
+ } ) . then ( ( result ) => {
126
+ expect ( result ) . to . deep . equal ( { headers : { 'Content-Disposition' : 'attachment' , 'Content-Type' : 'application/json' } , statusCode : 200 , body : 'filedata' , isBase64Encoded : false } )
127
+ } )
128
+ } ) // end it
129
+
102
130
} ) // end HEADER tests
0 commit comments