2 var express = require('../')
3 , request = require('supertest')
4 , assert = require('assert');
6 describe('req', function(){
7 describe('.get(field)', function(){
8 it('should return the header field value', function(done){
11 app.use(function(req, res){
12 assert(req.get('Something-Else') === undefined);
13 res.end(req.get('Content-Type'));
18 .set('Content-Type', 'application/json')
19 .expect('application/json', done);
22 it('should special-case Referer', function(done){
25 app.use(function(req, res){
26 res.end(req.get('Referer'));
31 .set('Referrer', 'http://foobar.com')
32 .expect('http://foobar.com', done);
35 it('should throw missing header name', function (done) {
38 app.use(function (req, res) {
44 .expect(500, /TypeError: name argument is required to req.get/, done)
47 it('should throw for non-string header name', function (done) {
50 app.use(function (req, res) {
56 .expect(500, /TypeError: name must be a string to req.get/, done)