Skip to content
Myr

req.get.js

This file

Path

test/req.get.js

60 lines · 1.4 KiB · JavaScript

Last changed by

tests: use strict modeDouglas Christopher Wilsonbefore adoptiona659137

History of this file

Take it

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

tests: use strict modeDouglas Christopher Wilsonbefore adoptiona659137

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

docs: add link to contributing guideJames Georgebefore adoptionb02d3a1

lines 2–60why, 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 })3536 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 })59 })60})