Skip to content
Myr

req.range.js

This file

Path

test/req.range.js

103 lines · 2.3 KiB · JavaScript

Last changed by

Merge tag '4.15.4'Douglas Christopher Wilsonbefore adoptionc319fe2

History of this file

Take it

The walk stopped after 200 commits: lines older than a01326a point at it.

Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a

lines 1–2why, one step back
1
2var express = require('..');

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

line 3why, one step back
3var request = require('supertest')

Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a

lines 4–6why, one step back
4
5describe('req', function(){6 describe('.range(size)', function(){

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 7–17why, one step back
7 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)

Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a

lines 18–19why, one step back
18 })
19

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 20–30why, one step back
20 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)

Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a

lines 31–32why, one step back
31 })
32

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 33–43why, one step back
33 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)

Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a

lines 44–45why, one step back
44 })
45

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 46–56why, one step back
46 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)

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 57why, one step back
57 })

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 58–82why, one step back
58
59 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 })

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

lines 83–86why, one step back
83 })
8485 describe('.range(size, options)', function(){86 describe('with "combine: true" option', function(){

Merge tag '4.15.0'Douglas Christopher Wilsonbefore adoption501e24e

lines 87–99why, one step back
87 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)

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

line 100why, one step back
100 })

Catch errors in multiple req.param(name, fn) handlersDouglas Christopher Wilsonbefore adoptiona01326a

lines 101–103why, one step back
101 })
102 })103})