Skip to content
Myr

req.get.js

This file

Path

test/req.get.js

59 lines · 1.4 KiB · JavaScript

Last changed by

Improve error with invalid arguments to req.get()Douglas Christopher Wilsonbefore adoptionc762b16

History of this file

Take it

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

4.13.1Douglas Christopher Wilsonbefore adoption2ac2509

lines 1–33why, one step back
1
2var express = require('../')3 , request = require('supertest')4 , assert = require('assert');56describe('req', function(){7 describe('.get(field)', function(){8 it('should return the header field value', function(done){9 var app = express();1011 app.use(function(req, res){12 assert(req.get('Something-Else') === undefined);13 res.end(req.get('Content-Type'));14 });1516 request(app)17 .post('/')18 .set('Content-Type', 'application/json')19 .expect('application/json', done);20 })2122 it('should special-case Referer', function(done){23 var app = express();2425 app.use(function(req, res){26 res.end(req.get('Referer'));27 });2829 request(app)30 .post('/')31 .set('Referrer', 'http://foobar.com')32 .expect('http://foobar.com', done);33 })

Improve error with invalid arguments to req.get()Douglas Christopher Wilsonbefore adoptionc762b16

lines 34–57why, one step back
34
35 it('should throw missing header name', function (done) {36 var app = express()3738 app.use(function (req, res) {39 res.end(req.get())40 })4142 request(app)43 .get('/')44 .expect(500, /TypeError: name argument is required to req.get/, done)45 })4647 it('should throw for non-string header name', function (done) {48 var app = express()4950 app.use(function (req, res) {51 res.end(req.get(42))52 })5354 request(app)55 .get('/')56 .expect(500, /TypeError: name must be a string to req.get/, done)57 })

4.13.1Douglas Christopher Wilsonbefore adoption2ac2509

lines 58–59why, one step back
58 })
59})