req.get.js
This file
Path
test/req.get.js
60 lines · 1.4 KiB · JavaScript
Last changed by
fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
History of this fileTake it
The walk stopped after 200 commits: lines older than 2a0c35a point at it.
Merge tag '4.17.3'Douglas Christopher Wilsonbefore adoption318fd4b
line 1why, one step back1'use strict'Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 2–4why, one step back23var express = require('../')4 , request = require('supertest')fix(refactor): prefix built-in node module importsSzymon Łągiewkabefore adoption4111359
line 5why, one step back5 , assert = require('node:assert');Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 6–34why, one step back67describe('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 back3536 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 })Invoke callback for sendfile when client abortsDouglas Christopher Wilsonbefore adoption2a0c35a
lines 59–60why, one step back59 })60})