app.head.js
This file
Path
test/app.head.js
66 lines · 1.3 KiB · JavaScript
Last changed by
Include ETag in HEAD requestsTiago Relvaobefore adoption3c0ec59
History of this fileTake it
The walk stopped after 200 commits: lines older than a10f695 point at it.
pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
line 1why, one step back1remove unnecessary test/support/httpJonathan Ongbefore adoption328c6d3
lines 2–4why, one step back2var express = require('../');3var request = require('supertest');4var assert = require('assert');pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 5–18why, one step back56describe('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 })Include ETag in HEAD requestsTiago Relvaobefore adoption3c0ec59
lines 19–41why, one step back1920 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 assert.deepEqual(res.headers, headers);38 done();39 });40 });41 })pin jade dev dep so tests do not breakTJ Holowaychukbefore adoptiona10f695
lines 42–66why, one step back42})4344describe('app.head()', function(){45 it('should override', function(done){46 var app = express()47 , called;4849 app.head('/tobi', function(req, res){50 called = true;51 res.end('');52 });5354 app.get('/tobi', function(req, res){55 assert(0, 'should not call GET');56 res.send('tobi');57 });5859 request(app)60 .head('/tobi')61 .expect(200, function(){62 assert(called);63 done();64 });65 })66})