req.range.js
This file
Path
test/req.range.js
103 lines · 2.3 KiB · JavaScript
Last changed by
lint: remove all unused varaiblesDouglas Christopher Wilsonbefore adoptione006622
History of this fileTake it
The walk stopped after 200 commits: lines older than dc48f27 point at it.
deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27
lines 1–2why, one step back12var express = require('..');tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
line 3why, one step back3var request = require('supertest')deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27
lines 4–6why, one step back45describe('req', function(){6 describe('.range(size)', function(){tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 7–17why, one step back7 it('should return parsed ranges', function (done) {8 var app = express()910 app.use(function (req, res) {11 res.json(req.range(120))12 })1314 request(app)15 .get('/')16 .set('Range', 'bytes=0-50,51-100')17 .expect(200, '[{"start":0,"end":50},{"start":51,"end":100}]', done)deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27
lines 18–19why, one step back18 })19tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 20–30why, one step back20 it('should cap to the given size', function (done) {21 var app = express()2223 app.use(function (req, res) {24 res.json(req.range(75))25 })2627 request(app)28 .get('/')29 .set('Range', 'bytes=0-100')30 .expect(200, '[{"start":0,"end":74}]', done)deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27
lines 31–32why, one step back31 })32tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 33–43why, one step back33 it('should cap to the given size when open-ended', function (done) {34 var app = express()3536 app.use(function (req, res) {37 res.json(req.range(75))38 })3940 request(app)41 .get('/')42 .set('Range', 'bytes=0-')43 .expect(200, '[{"start":0,"end":74}]', done)deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27
lines 44–45why, one step back44 })45tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 46–56why, one step back46 it('should have a .type', function (done) {47 var app = express()4849 app.use(function (req, res) {50 res.json(req.range(120).type)51 })5253 request(app)54 .get('/')55 .set('Range', 'bytes=0-100')56 .expect(200, '"bytes"', done)deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27
line 57why, one step back57 })tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 58–82why, one step back5859 it('should accept any type', function (done) {60 var app = express()6162 app.use(function (req, res) {63 res.json(req.range(120).type)64 })6566 request(app)67 .get('/')68 .set('Range', 'users=0-2')69 .expect(200, '"users"', done)70 })7172 it('should return undefined if no range', function (done) {73 var app = express()7475 app.use(function (req, res) {76 res.send(String(req.range(120)))77 })7879 request(app)80 .get('/')81 .expect(200, 'undefined', done)82 })deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27
lines 83–86why, one step back83 })8485 describe('.range(size, options)', function(){86 describe('with "combine: true" option', function(){tests: update req.range tests to run through expressDouglas Christopher Wilsonbefore adoption3e3d357
lines 87–99why, one step back87 it('should return combined ranges', function (done) {88 var app = express()8990 app.use(function (req, res) {91 res.json(req.range(120, {92 combine: true93 }))94 })9596 request(app)97 .get('/')98 .set('Range', 'bytes=0-50,51-100')99 .expect(200, '[{"start":0,"end":100}]', done)deps: update example dependenciesDouglas Christopher Wilsonbefore adoptiondc48f27
lines 100–103why, one step back100 })101 })102 })103})