From da6cb0ed8a4c9a5048cf391a32f9fab1960d9284 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Wed, 2 Feb 2022 15:15:41 -0500 Subject: [PATCH] tests: add range tests to res.download --- test/res.download.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/res.download.js b/test/res.download.js index cf3b3ca53e..658d80af4f 100644 --- a/test/res.download.js +++ b/test/res.download.js @@ -20,6 +20,33 @@ describe('res', function(){ .expect('Content-Disposition', 'attachment; filename="user.html"') .expect(200, '

{{user.name}}

', done) }) + + it('should accept range requests', function (done) { + var app = express() + + app.get('/', function (req, res) { + res.download('test/fixtures/user.html') + }) + + request(app) + .get('/') + .expect('Accept-Ranges', 'bytes') + .expect(200, '

{{user.name}}

', done) + }) + + it('should respond with requested byte range', function (done) { + var app = express() + + app.get('/', function (req, res) { + res.download('test/fixtures/user.html') + }) + + request(app) + .get('/') + .set('Range', 'bytes=0-2') + .expect('Content-Range', 'bytes 0-2/20') + .expect(206, '

', done) + }) }) describe('.download(path, filename)', function(){