req.range.js
This file
Path
test/req.range.js
104 lines · 2.3 KiB · JavaScript
Last changed by
tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
History of this fileTake it
The walk stopped after 200 commits: lines older than 2a45589 point at it.
Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 1–3why, one step back12var assert = require('assert');3var express = require('..');tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
line 4why, one step back4var request = require('supertest')Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 5–7why, one step back56describe('req', function(){7 describe('.range(size)', function(){tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 8–18why, one step back8 it('should return parsed ranges', function (done) {9 var app = express()1011 app.use(function (req, res) {12 res.json(req.range(120))13 })1415 request(app)16 .get('/')17 .set('Range', 'bytes=0-50,51-100')18 .expect(200, '[{"start":0,"end":50},{"start":51,"end":100}]', done)Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 19–20why, one step back19 })20tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 21–31why, one step back21 it('should cap to the given size', function (done) {22 var app = express()2324 app.use(function (req, res) {25 res.json(req.range(75))26 })2728 request(app)29 .get('/')30 .set('Range', 'bytes=0-100')31 .expect(200, '[{"start":0,"end":74}]', done)Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 32–33why, one step back32 })33tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 34–44why, one step back34 it('should cap to the given size when open-ended', function (done) {35 var app = express()3637 app.use(function (req, res) {38 res.json(req.range(75))39 })4041 request(app)42 .get('/')43 .set('Range', 'bytes=0-')44 .expect(200, '[{"start":0,"end":74}]', done)Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 45–46why, one step back45 })46tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 47–57why, one step back47 it('should have a .type', function (done) {48 var app = express()4950 app.use(function (req, res) {51 res.json(req.range(120).type)52 })5354 request(app)55 .get('/')56 .set('Range', 'bytes=0-100')57 .expect(200, '"bytes"', done)Add "options" argument to req.rangeDouglas Christopher Wilsonbefore adoption5d642af
line 58why, one step back58 })tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 59–83why, one step back5960 it('should accept any type', function (done) {61 var app = express()6263 app.use(function (req, res) {64 res.json(req.range(120).type)65 })6667 request(app)68 .get('/')69 .set('Range', 'users=0-2')70 .expect(200, '"users"', done)71 })7273 it('should return undefined if no range', function (done) {74 var app = express()7576 app.use(function (req, res) {77 res.send(String(req.range(120)))78 })7980 request(app)81 .get('/')82 .expect(200, 'undefined', done)83 })Add "options" argument to req.rangeDouglas Christopher Wilsonbefore adoption5d642af
lines 84–87why, one step back84 })8586 describe('.range(size, options)', function(){87 describe('with "combine: true" option', function(){tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 88–100why, one step back88 it('should return combined ranges', function (done) {89 var app = express()9091 app.use(function (req, res) {92 res.json(req.range(120, {93 combine: true94 }))95 })9697 request(app)98 .get('/')99 .set('Range', 'bytes=0-50,51-100')100 .expect(200, '[{"start":0,"end":100}]', done)Add "options" argument to req.rangeDouglas Christopher Wilsonbefore adoption5d642af
line 101why, one step back101 })Add settings to debug outputDouglas Christopher Wilsonbefore adoption2a45589
lines 102–104why, one step back102 })103 })104})