req.range.js
This file
Path
test/req.range.js
38 lines · 1016 bytes · JavaScript
Last changed by
Merge tag '3.8.0'Douglas Christopher Wilsonbefore adoptiondb4a061
History of this fileTake it
The walk stopped after 200 commits: lines older than a71d264 point at it.
fix weird variable name in exampleTJ Holowaychukbefore adoptiona71d264
line 1why, one step back1Merge tag '3.8.0'Douglas Christopher Wilsonbefore adoptiondb4a061
lines 2–3why, one step back2var assert = require('assert');3var express = require('..');fix weird variable name in exampleTJ Holowaychukbefore adoptiona71d264
lines 4–29why, one step back45function 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(){15 var ret = [{ start: 0, end: 50 }, { start: 60, end: 100 }];16 ret.type = 'bytes';17 req('bytes=0-50,60-100').range(120).should.eql(ret);18 })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);Merge tag '3.8.0'Douglas Christopher Wilsonbefore adoptiondb4a061
lines 30–35why, one step back30 })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);fix weird variable name in exampleTJ Holowaychukbefore adoptiona71d264
lines 36–38why, one step back36 })37 })38})