index.js
1.28 KB
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
var dnsPrefetchControl = require('..')
var assert = require('assert')
var connect = require('connect')
var request = require('supertest')
describe('dnsPrefetchControl', function () {
function use () {
var result = connect()
result.use(dnsPrefetchControl.apply(null, arguments))
result.use(function (req, res) {
res.end('Hello world!')
})
return result
}
it('continues onto the following middleware', function (done) {
var app = use()
request(app).get('/')
.expect('Hello world!')
.end(done)
})
it('sets the header to "off" by default', function (done) {
var app = use()
request(app).get('/')
.expect('X-DNS-Prefetch-Control', 'off')
.end(done)
})
it('can set header to "off" with configuration', function (done) {
var app = use({ allow: false })
request(app).get('/')
.expect('X-DNS-Prefetch-Control', 'off')
.end(done)
})
it('can set header to "on" with configuration', function (done) {
var app = use({ allow: true })
request(app).get('/')
.expect('X-DNS-Prefetch-Control', 'on')
.end(done)
})
it('names its function and middleware', function () {
assert.equal(dnsPrefetchControl.name, 'dnsPrefetchControl')
assert.equal(dnsPrefetchControl().name, 'dnsPrefetchControl')
})
})