Skip to content
Myr

req.get.js

This file

Path

test/req.get.js

60 lines · 1.4 KiB · JavaScript

Last changed by

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

History of this file

Take it

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

Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b

line 1why, one step back
1'use strict'

Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2

lines 2–34why, one step back
2
3var express = require('../')4 , request = require('supertest')5 , assert = require('assert');67describe('req', function(){8 describe('.get(field)', function(){9 it('should return the header field value', function(done){10 var app = express();1112 app.use(function(req, res){13 assert(req.get('Something-Else') === undefined);14 res.end(req.get('Content-Type'));15 });1617 request(app)18 .post('/')19 .set('Content-Type', 'application/json')20 .expect('application/json', done);21 })2223 it('should special-case Referer', function(done){24 var app = express();2526 app.use(function(req, res){27 res.end(req.get('Referer'));28 });2930 request(app)31 .post('/')32 .set('Referrer', 'http://foobar.com')33 .expect('http://foobar.com', done);34 })

Merge tag '4.14.0'Douglas Christopher Wilsonbefore adoption1dbfee6

lines 35–58why, one step back
35
36 it('should throw missing header name', function (done) {37 var app = express()3839 app.use(function (req, res) {40 res.end(req.get())41 })4243 request(app)44 .get('/')45 .expect(500, /TypeError: name argument is required to req.get/, done)46 })4748 it('should throw for non-string header name', function (done) {49 var app = express()5051 app.use(function (req, res) {52 res.end(req.get(42))53 })5455 request(app)56 .get('/')57 .expect(500, /TypeError: name must be a string to req.get/, done)58 })

Merge tag '3.15.2'Douglas Christopher Wilsonbefore adoption454c4b2

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