From c0e5dc1d3a35335c943a72f9b17f2e42559a7e45 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 0000000000..fb43877709 --- /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 5f0772697c..9321f3bf95 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 a0aa7b75d9..ae44388354 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)