Skip to content

Commit f86af2d

Browse files
committed
add additional attachment tests
1 parent 3643713 commit f86af2d

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

test/attachments.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,21 @@ api.get('/attachment/png', function(req,res) {
3535
})
3636

3737
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')
3939
})
4040

4141
api.get('/attachment/custom', function(req,res) {
4242
res.attachment('/test/path/foo.test').send('filedata')
4343
})
4444

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+
4553

4654
/******************************************************************************/
4755
/*** BEGIN TESTS ***/
@@ -99,4 +107,24 @@ describe('Attachment Tests:', function() {
99107
})
100108
}) // end it
101109

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+
102130
}) // end HEADER tests

0 commit comments

Comments
 (0)