req.range.js
This file
Path
test/req.range.js
48 lines · 1.3 KiB · JavaScript
Last changed by
Add "options" argument to req.rangeDouglas Christopher Wilsonbefore adoption5d642af
History of this fileTake it
The walk stopped after 200 commits: lines older than e03ed05 point at it.
deps: type-is@~1.6.0Douglas Christopher Wilsonbefore adoptione03ed05
lines 1–14why, one step back12var assert = require('assert');3var express = require('..');45function req(ret) {6 return {7 get: function(){ return ret }8 , __proto__: express.request9 };10}1112describe('req', function(){13 describe('.range(size)', function(){14 it('should return parsed ranges', function(){Add "options" argument to req.rangeDouglas Christopher Wilsonbefore adoption5d642af
lines 15–17why, one step back15 var ranges = [{ start: 0, end: 50 }, { start: 51, end: 100 }]16 ranges.type = 'bytes'17 assert.deepEqual(req('bytes=0-50,51-100').range(120), ranges)deps: type-is@~1.6.0Douglas Christopher Wilsonbefore adoptione03ed05
lines 18–35why, one step back18 })1920 it('should cap to the given size', function(){21 var ret = [{ start: 0, end: 74 }];22 ret.type = 'bytes';23 req('bytes=0-100').range(75).should.eql(ret);24 })2526 it('should have a .type', function(){27 var ret = [{ start: 0, end: Infinity }];28 ret.type = 'users';29 req('users=0-').range(Infinity).should.eql(ret);30 })3132 it('should return undefined if no range', function(){33 var ret = [{ start: 0, end: 50 }, { start: 60, end: 100 }];34 ret.type = 'bytes';35 assert(req('').range(120) === undefined);Add "options" argument to req.rangeDouglas Christopher Wilsonbefore adoption5d642af
lines 36–45why, one step back36 })37 })3839 describe('.range(size, options)', function(){40 describe('with "combine: true" option', function(){41 it('should return combined ranges', function(){42 var ranges = [{ start: 0, end: 100 }]43 ranges.type = 'bytes'44 assert.deepEqual(req('bytes=0-50,51-100').range(120, { combine: true }), ranges)45 })deps: type-is@~1.6.0Douglas Christopher Wilsonbefore adoptione03ed05
lines 46–48why, one step back46 })47 })48})