From 3bb6d96ba9f386d8b328605ba762656cc759104b Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 15 Dec 2021 21:06:33 -0500 Subject: [PATCH] examples: demonstrate sub directory download --- examples/downloads/files/notes/groceries.txt | 3 +++ examples/downloads/index.js | 11 ++++++----- test/acceptance/downloads.js | 9 +++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 examples/downloads/files/notes/groceries.txt diff --git a/examples/downloads/files/notes/groceries.txt b/examples/downloads/files/notes/groceries.txt new file mode 100644 index 00000000..fb438777 --- /dev/null +++ b/examples/downloads/files/notes/groceries.txt @@ -0,0 +1,3 @@ +* milk +* eggs +* bread diff --git a/examples/downloads/index.js b/examples/downloads/index.js index 5f077269..9321f3bf 100644 --- a/examples/downloads/index.js +++ b/examples/downloads/index.js @@ -7,11 +7,12 @@ var path = require('path'); var app = module.exports = express(); app.get('/', function(req, res){ - res.send(''); + res.send('') }); // /files/* is accessed via req.params[0] diff --git a/test/acceptance/downloads.js b/test/acceptance/downloads.js index a0aa7b75..ae443883 100644 --- a/test/acceptance/downloads.js +++ b/test/acceptance/downloads.js @@ -11,6 +11,15 @@ describe('downloads', function(){ }) }) + describe('GET /files/notes/groceries.txt', function () { + it('should have a download header', function (done) { + request(app) + .get('/files/notes/groceries.txt') + .expect('Content-Disposition', 'attachment; filename="groceries.txt"') + .expect(200, done) + }) + }) + describe('GET /files/amazing.txt', function(){ it('should have a download header', function(done){ request(app) -- 2.11.4.GIT