Skip to content

Commit

Permalink
tests: add range tests to res.download
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Feb 2, 2022
1 parent 00ad5be commit da6cb0e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/res.download.js
Expand Up @@ -20,6 +20,33 @@ describe('res', function(){
.expect('Content-Disposition', 'attachment; filename="user.html"')
.expect(200, '<p>{{user.name}}</p>', 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, '<p>{{user.name}}</p>', 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, '<p>', done)
})
})

describe('.download(path, filename)', function(){
Expand Down

0 comments on commit da6cb0e

Please sign in to comment.