1
- var request = require ( 'supertest' ) ;
2
- var koa = require ( 'koa' ) ;
3
- var cacheControl = require ( '..' ) ;
4
- var fs = require ( 'fs' ) ;
1
+ const request = require ( 'supertest' ) ;
2
+ const koa = require ( 'koa' ) ;
3
+ const cacheControl = require ( '..' ) ;
4
+ const fs = require ( 'fs' ) ;
5
5
6
6
describe ( 'cacheControl()' , function ( ) {
7
7
describe ( 'default configuration' , function ( ) {
8
8
it ( 'uses defaults if nothing defined on request' , function ( done ) {
9
- var app = new koa ( ) ;
9
+ const app = new koa ( ) ;
10
10
11
11
app . use ( cacheControl ( {
12
12
maxAge : 4
@@ -25,7 +25,7 @@ describe('cacheControl()', function () {
25
25
26
26
describe ( 'override default configuration' , function ( ) {
27
27
it ( 'allows middleware to override options in incoming requests' , function ( done ) {
28
- var app = new koa ( ) ;
28
+ const app = new koa ( ) ;
29
29
30
30
app . use ( cacheControl ( {
31
31
maxAge : 4
@@ -46,7 +46,7 @@ describe('cacheControl()', function () {
46
46
} )
47
47
48
48
it ( 'allows middleware to override options on outgoing requests' , function ( done ) {
49
- var app = new koa ( ) ;
49
+ const app = new koa ( ) ;
50
50
51
51
app . use ( cacheControl ( {
52
52
maxAge : 300
@@ -73,7 +73,7 @@ describe('cacheControl()', function () {
73
73
74
74
describe ( 'public is set' , function ( ) {
75
75
it ( 'adds public flag to cache-control header' , function ( done ) {
76
- var app = new koa ( ) ;
76
+ const app = new koa ( ) ;
77
77
78
78
app . use ( cacheControl ( {
79
79
public : true
@@ -92,7 +92,7 @@ describe('cacheControl()', function () {
92
92
93
93
describe ( 'private is set' , function ( ) {
94
94
it ( 'adds private flag to cache-control header' , function ( done ) {
95
- var app = new koa ( ) ;
95
+ const app = new koa ( ) ;
96
96
97
97
app . use ( cacheControl ( {
98
98
private : true
@@ -109,7 +109,7 @@ describe('cacheControl()', function () {
109
109
} ) ;
110
110
111
111
it ( 'discards public flag in cache-control header' , function ( done ) {
112
- var app = new koa ( ) ;
112
+ const app = new koa ( ) ;
113
113
114
114
app . use ( cacheControl ( {
115
115
private : true ,
@@ -129,7 +129,7 @@ describe('cacheControl()', function () {
129
129
130
130
describe ( 'maxAge is set' , function ( ) {
131
131
it ( 'sets cache-control max-age section' , function ( done ) {
132
- var app = new koa ( ) ;
132
+ const app = new koa ( ) ;
133
133
134
134
app . use ( cacheControl ( {
135
135
maxAge : 4
@@ -148,7 +148,7 @@ describe('cacheControl()', function () {
148
148
149
149
describe ( 'staleIfError is set' , function ( ) {
150
150
it ( 'sets cache-control header with stale-if-error' , function ( done ) {
151
- var app = new koa ( ) ;
151
+ const app = new koa ( ) ;
152
152
153
153
app . use ( cacheControl ( {
154
154
staleIfError : 320
@@ -167,7 +167,7 @@ describe('cacheControl()', function () {
167
167
168
168
describe ( 'staleWhileRevalidate is set' , function ( ) {
169
169
it ( 'sets cache-control header with stale-while-revalidate' , function ( done ) {
170
- var app = new koa ( ) ;
170
+ const app = new koa ( ) ;
171
171
172
172
app . use ( cacheControl ( {
173
173
staleWhileRevalidate : 320
@@ -186,7 +186,7 @@ describe('cacheControl()', function () {
186
186
187
187
describe ( 'mustRevalidate is set' , function ( ) {
188
188
it ( 'sets cache-control header with must-revalidate' , function ( done ) {
189
- var app = new koa ( ) ;
189
+ const app = new koa ( ) ;
190
190
191
191
app . use ( cacheControl ( {
192
192
mustRevalidate : true
@@ -203,7 +203,7 @@ describe('cacheControl()', function () {
203
203
} ) ;
204
204
205
205
it ( 'overthrows stale-while-revalidate and stale-if-error' , function ( done ) {
206
- var app = new koa ( ) ;
206
+ const app = new koa ( ) ;
207
207
208
208
app . use ( cacheControl ( {
209
209
mustRevalidate : true ,
@@ -224,7 +224,7 @@ describe('cacheControl()', function () {
224
224
225
225
describe ( 'when noCache is true' , function ( ) {
226
226
it ( 'adds no-cache to Cache-Control header' , function ( done ) {
227
- var app = new koa ( ) ;
227
+ const app = new koa ( ) ;
228
228
229
229
app . use ( cacheControl ( {
230
230
noCache : true
@@ -241,7 +241,7 @@ describe('cacheControl()', function () {
241
241
} ) ;
242
242
243
243
it ( 'sets maxAge to 0' , function ( done ) {
244
- var app = new koa ( ) ;
244
+ const app = new koa ( ) ;
245
245
246
246
app . use ( cacheControl ( {
247
247
noCache : true ,
@@ -259,7 +259,7 @@ describe('cacheControl()', function () {
259
259
} ) ;
260
260
261
261
it ( 'removes sMaxAge' , function ( done ) {
262
- var app = new koa ( ) ;
262
+ const app = new koa ( ) ;
263
263
264
264
app . use ( cacheControl ( {
265
265
noCache : true ,
@@ -277,7 +277,7 @@ describe('cacheControl()', function () {
277
277
} ) ;
278
278
279
279
it ( 'ignores stale settings' , function ( done ) {
280
- var app = new koa ( ) ;
280
+ const app = new koa ( ) ;
281
281
282
282
app . use ( cacheControl ( {
283
283
noCache : true ,
@@ -298,7 +298,7 @@ describe('cacheControl()', function () {
298
298
299
299
describe ( 'when noStore is true' , function ( ) {
300
300
it ( 'sets Cache-Control no-store and no-cache' , function ( done ) {
301
- var app = new koa ( ) ;
301
+ const app = new koa ( ) ;
302
302
303
303
app . use ( cacheControl ( {
304
304
noStore : true
@@ -315,7 +315,7 @@ describe('cacheControl()', function () {
315
315
} ) ;
316
316
317
317
it ( 'sets maxAge to 0' , function ( done ) {
318
- var app = new koa ( ) ;
318
+ const app = new koa ( ) ;
319
319
320
320
app . use ( cacheControl ( {
321
321
noStore : true ,
@@ -335,7 +335,7 @@ describe('cacheControl()', function () {
335
335
336
336
describe ( 'when noTransform is set' , function ( ) {
337
337
it ( 'sets Cache-Control no-transform' , function ( done ) {
338
- var app = new koa ( ) ;
338
+ const app = new koa ( ) ;
339
339
340
340
app . use ( cacheControl ( {
341
341
noTransform : true
@@ -354,7 +354,7 @@ describe('cacheControl()', function () {
354
354
355
355
describe ( 'when proxyRevalidate' , function ( ) {
356
356
it ( 'sets Cache-Control proxy-revalidate' , function ( done ) {
357
- var app = new koa ( ) ;
357
+ const app = new koa ( ) ;
358
358
359
359
app . use ( cacheControl ( {
360
360
proxyRevalidate : true
@@ -374,7 +374,7 @@ describe('cacheControl()', function () {
374
374
375
375
describe ( 'when sMaxAge' , function ( ) {
376
376
it ( 'sets Cache-Control s-maxage property' , function ( done ) {
377
- var app = new koa ( ) ;
377
+ const app = new koa ( ) ;
378
378
379
379
app . use ( cacheControl ( {
380
380
sMaxAge : 10
@@ -393,7 +393,7 @@ describe('cacheControl()', function () {
393
393
394
394
describe ( 'when no cache properties set' , function ( ) {
395
395
it ( 'does not set a cache-control header' , function ( done ) {
396
- var app = new koa ( ) ;
396
+ const app = new koa ( ) ;
397
397
398
398
app . use ( cacheControl ( ) ) ;
399
399
0 commit comments