Skip to content

Commit 878c248

Browse files
committedSep 4, 2017
tests: use mocha context for server
1 parent e24fa4b commit 878c248

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed
 

‎test/test.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -106,47 +106,47 @@ describe('favicon()', function () {
106106
})
107107

108108
describe('requests', function () {
109-
var server
110109
before(function () {
111-
server = createServer()
110+
this.server = createServer()
112111
})
113112

114113
it('should serve icon', function (done) {
115-
request(server)
114+
request(this.server)
116115
.get('/favicon.ico')
117116
.expect('Content-Type', 'image/x-icon')
118117
.expect(200, done)
119118
})
120119

121120
it('should include cache-control', function (done) {
122-
request(server)
121+
request(this.server)
123122
.get('/favicon.ico')
124123
.expect('Cache-Control', /public/)
125124
.expect(200, done)
126125
})
127126

128127
it('should include strong etag', function (done) {
129-
request(server)
128+
request(this.server)
130129
.get('/favicon.ico')
131130
.expect('ETag', /^"[^"]+"$/)
132131
.expect(200, done)
133132
})
134133

135134
it('should deny POST', function (done) {
136-
request(server)
135+
request(this.server)
137136
.post('/favicon.ico')
138137
.expect('Allow', 'GET, HEAD, OPTIONS')
139138
.expect(405, done)
140139
})
141140

142141
it('should understand OPTIONS', function (done) {
143-
request(server)
142+
request(this.server)
144143
.options('/favicon.ico')
145144
.expect('Allow', 'GET, HEAD, OPTIONS')
146145
.expect(200, done)
147146
})
148147

149148
it('should 304 when If-None-Match matches', function (done) {
149+
var server = this.server
150150
request(server)
151151
.get('/favicon.ico')
152152
.expect(200, function (err, res) {
@@ -159,6 +159,7 @@ describe('favicon()', function () {
159159
})
160160

161161
it('should 304 when If-None-Match matches weakly', function (done) {
162+
var server = this.server
162163
request(server)
163164
.get('/favicon.ico')
164165
.expect(200, function (err, res) {
@@ -171,13 +172,13 @@ describe('favicon()', function () {
171172
})
172173

173174
it('should ignore non-favicon requests', function (done) {
174-
request(server)
175+
request(this.server)
175176
.get('/')
176177
.expect(404, 'oops', done)
177178
})
178179

179180
it('should work with query string', function (done) {
180-
request(server)
181+
request(this.server)
181182
.get('/favicon.ico?v=1')
182183
.expect('Content-Type', 'image/x-icon')
183184
.expect(200, done)

0 commit comments

Comments
 (0)
Please sign in to comment.