Skip to content

Commit da6cb0e

Browse files
committed
tests: add range tests to res.download
1 parent 00ad5be commit da6cb0e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/res.download.js

+27
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,33 @@ describe('res', function(){
2020
.expect('Content-Disposition', 'attachment; filename="user.html"')
2121
.expect(200, '<p>{{user.name}}</p>', done)
2222
})
23+
24+
it('should accept range requests', function (done) {
25+
var app = express()
26+
27+
app.get('/', function (req, res) {
28+
res.download('test/fixtures/user.html')
29+
})
30+
31+
request(app)
32+
.get('/')
33+
.expect('Accept-Ranges', 'bytes')
34+
.expect(200, '<p>{{user.name}}</p>', done)
35+
})
36+
37+
it('should respond with requested byte range', function (done) {
38+
var app = express()
39+
40+
app.get('/', function (req, res) {
41+
res.download('test/fixtures/user.html')
42+
})
43+
44+
request(app)
45+
.get('/')
46+
.set('Range', 'bytes=0-2')
47+
.expect('Content-Range', 'bytes 0-2/20')
48+
.expect(206, '<p>', done)
49+
})
2350
})
2451

2552
describe('.download(path, filename)', function(){

0 commit comments

Comments
 (0)