app.head.js
This file
Path
test/app.head.js
68 lines · 1.4 KiB · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 6bc7574 point at it.
docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 1–68why, one step back12var express = require('../');3var request = require('supertest');4var assert = require('assert');56describe('HEAD', function(){7 it('should default to GET', function(done){8 var app = express();910 app.get('/tobi', function(req, res){11 // send() detects HEAD12 res.send('tobi');13 });1415 request(app)16 .head('/tobi')17 .expect(200, done);18 })1920 it('should output the same headers as GET requests', function(done){21 var app = express();2223 app.get('/tobi', function(req, res){24 // send() detects HEAD25 res.send('tobi');26 });2728 request(app)29 .get('/tobi')30 .expect(200, function(err, res){31 if (err) return done(err);32 var headers = res.headers;33 request(app)34 .get('/tobi')35 .expect(200, function(err, res){36 if (err) return done(err);37 delete headers.date;38 delete res.headers.date;39 assert.deepEqual(res.headers, headers);40 done();41 });42 });43 })44})4546describe('app.head()', function(){47 it('should override', function(done){48 var app = express()49 , called;5051 app.head('/tobi', function(req, res){52 called = true;53 res.end('');54 });5556 app.get('/tobi', function(req, res){57 assert(0, 'should not call GET');58 res.send('tobi');59 });6061 request(app)62 .head('/tobi')63 .expect(200, function(){64 assert(called);65 done();66 });67 })68})