forked from expressjs/express
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.head.js
68 lines (57 loc) · 1.38 KB
/
app.head.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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);
delete headers.date;
delete res.headers.date;
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();
});
})
})