app.head.js
This file
Path
test/app.head.js
66 lines · 1.3 KiB · JavaScript
Last changed by
Revert "fix behavior of multiple app.VERB for the same path"Douglas Christopher Wilsonbefore adoption7f04916
History of this fileTake it
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
var express = require('../');var request = require('supertest');var assert = require('assert');
describe('HEAD', function(){ it('should default to GET', function(done){ var app = express();
app.get('/tobi', function(req, res){ // send() detects HEAD res.send('tobi'); });
request(app) .head('/tobi') .expect(200, done); })
it('should output the same headers as GET requests', function(done){ var app = express();
app.get('/tobi', function(req, res){ // send() detects HEAD res.send('tobi'); });
request(app) .get('/tobi') .expect(200, function(err, res){ if (err) return done(err); var headers = res.headers; request(app) .get('/tobi') .expect(200, function(err, res){ if (err) return done(err); assert.deepEqual(res.headers, headers); done(); }); }); })})
describe('app.head()', function(){ it('should override', function(done){ var app = express() , called;
app.head('/tobi', function(req, res){ called = true; res.end(''); });
app.get('/tobi', function(req, res){ assert(0, 'should not call GET'); res.send('tobi'); });
request(app) .head('/tobi') .expect(200, function(){ assert(called); done(); }); })})