@fastify/compress 8.0.0-pre.fv5.2 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { test } = require('tap')
3
+ const { describe, test } = require('node:test')
4
4
  const { createReadStream, readFile, readFileSync } = require('node:fs')
5
5
  const { Readable, Writable, PassThrough } = require('node:stream')
6
6
  const zlib = require('node:zlib')
@@ -10,8 +10,8 @@ const Fastify = require('fastify')
10
10
  const compressPlugin = require('../index')
11
11
  const { once } = require('node:events')
12
12
 
13
- test('When `global` is not set, it is `true` by default :', async (t) => {
14
- t.test('it should compress Buffer data using brotli when `Accept-Encoding` request header is `br`', async (t) => {
13
+ describe('When `global` is not set, it is `true` by default :', async () => {
14
+ test('it should compress Buffer data using brotli when `Accept-Encoding` request header is `br`', async (t) => {
15
15
  t.plan(1)
16
16
 
17
17
  const fastify = Fastify()
@@ -30,10 +30,10 @@ test('When `global` is not set, it is `true` by default :', async (t) => {
30
30
  }
31
31
  })
32
32
  const payload = zlib.brotliDecompressSync(response.rawPayload)
33
- t.equal(payload.toString('utf-8'), buf.toString())
33
+ t.assert.equal(payload.toString('utf-8'), buf.toString())
34
34
  })
35
35
 
36
- t.test('it should compress Buffer data using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
36
+ test('it should compress Buffer data using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
37
37
  t.plan(1)
38
38
 
39
39
  const fastify = Fastify()
@@ -52,10 +52,10 @@ test('When `global` is not set, it is `true` by default :', async (t) => {
52
52
  }
53
53
  })
54
54
  const payload = zlib.inflateSync(response.rawPayload)
55
- t.equal(payload.toString('utf-8'), buf.toString())
55
+ t.assert.equal(payload.toString('utf-8'), buf.toString())
56
56
  })
57
57
 
58
- t.test('it should compress Buffer data using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
58
+ test('it should compress Buffer data using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
59
59
  t.plan(1)
60
60
 
61
61
  const fastify = Fastify()
@@ -74,10 +74,10 @@ test('When `global` is not set, it is `true` by default :', async (t) => {
74
74
  }
75
75
  })
76
76
  const payload = zlib.gunzipSync(response.rawPayload)
77
- t.equal(payload.toString('utf-8'), buf.toString())
77
+ t.assert.equal(payload.toString('utf-8'), buf.toString())
78
78
  })
79
79
 
80
- t.test('it should compress JSON data using brotli when `Accept-Encoding` request header is `br`', async (t) => {
80
+ test('it should compress JSON data using brotli when `Accept-Encoding` request header is `br`', async (t) => {
81
81
  t.plan(1)
82
82
 
83
83
  const fastify = Fastify()
@@ -97,10 +97,10 @@ test('When `global` is not set, it is `true` by default :', async (t) => {
97
97
  }
98
98
  })
99
99
  const payload = zlib.brotliDecompressSync(response.rawPayload)
100
- t.equal(payload.toString('utf-8'), JSON.stringify(json))
100
+ t.assert.equal(payload.toString('utf-8'), JSON.stringify(json))
101
101
  })
102
102
 
103
- t.test('it should compress JSON data using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
103
+ test('it should compress JSON data using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
104
104
  t.plan(1)
105
105
 
106
106
  const fastify = Fastify()
@@ -120,10 +120,10 @@ test('When `global` is not set, it is `true` by default :', async (t) => {
120
120
  }
121
121
  })
122
122
  const payload = zlib.inflateSync(response.rawPayload)
123
- t.equal(payload.toString('utf-8'), JSON.stringify(json))
123
+ t.assert.equal(payload.toString('utf-8'), JSON.stringify(json))
124
124
  })
125
125
 
126
- t.test('it should compress JSON data using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
126
+ test('it should compress JSON data using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
127
127
  t.plan(1)
128
128
 
129
129
  const fastify = Fastify()
@@ -142,10 +142,10 @@ test('When `global` is not set, it is `true` by default :', async (t) => {
142
142
  }
143
143
  })
144
144
  const payload = zlib.gunzipSync(response.rawPayload)
145
- t.equal(payload.toString('utf-8'), JSON.stringify(json))
145
+ t.assert.equal(payload.toString('utf-8'), JSON.stringify(json))
146
146
  })
147
147
 
148
- t.test('it should compress string data using brotli when `Accept-Encoding` request header is `br', async (t) => {
148
+ test('it should compress string data using brotli when `Accept-Encoding` request header is `br', async (t) => {
149
149
  t.plan(1)
150
150
 
151
151
  const fastify = Fastify()
@@ -165,10 +165,10 @@ test('When `global` is not set, it is `true` by default :', async (t) => {
165
165
  }
166
166
  })
167
167
  const payload = zlib.brotliDecompressSync(response.rawPayload)
168
- t.equal(payload.toString('utf-8'), 'hello')
168
+ t.assert.equal(payload.toString('utf-8'), 'hello')
169
169
  })
170
170
 
171
- t.test('it should compress string data using deflate when `Accept-Encoding` request header is `deflate', async (t) => {
171
+ test('it should compress string data using deflate when `Accept-Encoding` request header is `deflate', async (t) => {
172
172
  t.plan(1)
173
173
 
174
174
  const fastify = Fastify()
@@ -188,10 +188,10 @@ test('When `global` is not set, it is `true` by default :', async (t) => {
188
188
  }
189
189
  })
190
190
  const payload = zlib.inflateSync(response.rawPayload)
191
- t.equal(payload.toString('utf-8'), 'hello')
191
+ t.assert.equal(payload.toString('utf-8'), 'hello')
192
192
  })
193
193
 
194
- t.test('it should compress string data using gzip when `Accept-Encoding` request header is `gzip', async (t) => {
194
+ test('it should compress string data using gzip when `Accept-Encoding` request header is `gzip', async (t) => {
195
195
  t.plan(1)
196
196
 
197
197
  const fastify = Fastify()
@@ -211,12 +211,12 @@ test('When `global` is not set, it is `true` by default :', async (t) => {
211
211
  }
212
212
  })
213
213
  const payload = zlib.gunzipSync(response.rawPayload)
214
- t.equal(payload.toString('utf-8'), 'hello')
214
+ t.assert.equal(payload.toString('utf-8'), 'hello')
215
215
  })
216
216
  })
217
217
 
218
- test('It should send compressed Stream data when `global` is `true` :', async (t) => {
219
- t.test('using brotli when `Accept-Encoding` request header is `br`', async (t) => {
218
+ describe('It should send compressed Stream data when `global` is `true` :', async () => {
219
+ test('using brotli when `Accept-Encoding` request header is `br`', async (t) => {
220
220
  t.plan(3)
221
221
 
222
222
  const fastify = Fastify()
@@ -237,12 +237,12 @@ test('It should send compressed Stream data when `global` is `true` :', async (t
237
237
  })
238
238
  const file = readFileSync('./package.json', 'utf8')
239
239
  const payload = zlib.brotliDecompressSync(response.rawPayload)
240
- t.equal(response.headers.vary, 'accept-encoding')
241
- t.equal(response.headers['content-encoding'], 'br')
242
- t.equal(payload.toString('utf-8'), file)
240
+ t.assert.equal(response.headers.vary, 'accept-encoding')
241
+ t.assert.equal(response.headers['content-encoding'], 'br')
242
+ t.assert.equal(payload.toString('utf-8'), file)
243
243
  })
244
244
 
245
- t.test('using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
245
+ test('using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
246
246
  t.plan(4)
247
247
 
248
248
  const fastify = Fastify()
@@ -263,13 +263,13 @@ test('It should send compressed Stream data when `global` is `true` :', async (t
263
263
  })
264
264
  const file = readFileSync('./package.json', 'utf8')
265
265
  const payload = zlib.inflateSync(response.rawPayload)
266
- t.equal(response.headers.vary, 'accept-encoding')
267
- t.equal(response.headers['content-encoding'], 'deflate')
268
- t.notOk(response.headers['content-length'], 'no content length')
269
- t.equal(payload.toString('utf-8'), file)
266
+ t.assert.equal(response.headers.vary, 'accept-encoding')
267
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
268
+ t.assert.ok(!response.headers['content-length'], 'no content length')
269
+ t.assert.equal(payload.toString('utf-8'), file)
270
270
  })
271
271
 
272
- t.test('using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
272
+ test('using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
273
273
  t.plan(3)
274
274
 
275
275
  const fastify = Fastify()
@@ -290,14 +290,14 @@ test('It should send compressed Stream data when `global` is `true` :', async (t
290
290
  })
291
291
  const file = readFileSync('./package.json', 'utf8')
292
292
  const payload = zlib.gunzipSync(response.rawPayload)
293
- t.equal(response.headers.vary, 'accept-encoding')
294
- t.equal(response.headers['content-encoding'], 'gzip')
295
- t.equal(payload.toString('utf-8'), file)
293
+ t.assert.equal(response.headers.vary, 'accept-encoding')
294
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
295
+ t.assert.equal(payload.toString('utf-8'), file)
296
296
  })
297
297
  })
298
298
 
299
- test('It should send compressed Buffer data when `global` is `true` :', async (t) => {
300
- t.test('using brotli when `Accept-Encoding` request header is `br`', async (t) => {
299
+ describe('It should send compressed Buffer data when `global` is `true` :', async () => {
300
+ test('using brotli when `Accept-Encoding` request header is `br`', async (t) => {
301
301
  t.plan(1)
302
302
 
303
303
  const fastify = Fastify()
@@ -316,10 +316,10 @@ test('It should send compressed Buffer data when `global` is `true` :', async (t
316
316
  }
317
317
  })
318
318
  const payload = zlib.brotliDecompressSync(response.rawPayload)
319
- t.equal(payload.toString('utf-8'), buf.toString())
319
+ t.assert.equal(payload.toString('utf-8'), buf.toString())
320
320
  })
321
321
 
322
- t.test('using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
322
+ test('using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
323
323
  t.plan(1)
324
324
 
325
325
  const fastify = Fastify()
@@ -338,10 +338,10 @@ test('It should send compressed Buffer data when `global` is `true` :', async (t
338
338
  }
339
339
  })
340
340
  const payload = zlib.inflateSync(response.rawPayload)
341
- t.equal(payload.toString('utf-8'), buf.toString())
341
+ t.assert.equal(payload.toString('utf-8'), buf.toString())
342
342
  })
343
343
 
344
- t.test('using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
344
+ test('using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
345
345
  t.plan(1)
346
346
 
347
347
  const fastify = Fastify()
@@ -360,12 +360,12 @@ test('It should send compressed Buffer data when `global` is `true` :', async (t
360
360
  }
361
361
  })
362
362
  const payload = zlib.gunzipSync(response.rawPayload)
363
- t.equal(payload.toString('utf-8'), buf.toString())
363
+ t.assert.equal(payload.toString('utf-8'), buf.toString())
364
364
  })
365
365
  })
366
366
 
367
- test('It should send compressed JSON data when `global` is `true` :', async (t) => {
368
- t.test('using brotli when `Accept-Encoding` request header is `br`', async (t) => {
367
+ describe('It should send compressed JSON data when `global` is `true` :', async () => {
368
+ test('using brotli when `Accept-Encoding` request header is `br`', async (t) => {
369
369
  t.plan(1)
370
370
 
371
371
  const fastify = Fastify()
@@ -384,10 +384,10 @@ test('It should send compressed JSON data when `global` is `true` :', async (t)
384
384
  }
385
385
  })
386
386
  const payload = zlib.brotliDecompressSync(response.rawPayload)
387
- t.equal(payload.toString('utf-8'), JSON.stringify(json))
387
+ t.assert.equal(payload.toString('utf-8'), JSON.stringify(json))
388
388
  })
389
389
 
390
- t.test('using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
390
+ test('using deflate when `Accept-Encoding` request header is `deflate`', async (t) => {
391
391
  t.plan(1)
392
392
 
393
393
  const fastify = Fastify()
@@ -406,10 +406,10 @@ test('It should send compressed JSON data when `global` is `true` :', async (t)
406
406
  }
407
407
  })
408
408
  const payload = zlib.inflateSync(response.rawPayload)
409
- t.equal(payload.toString('utf-8'), JSON.stringify(json))
409
+ t.assert.equal(payload.toString('utf-8'), JSON.stringify(json))
410
410
  })
411
411
 
412
- t.test('using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
412
+ test('using gzip when `Accept-Encoding` request header is `gzip`', async (t) => {
413
413
  t.plan(1)
414
414
 
415
415
  const fastify = Fastify()
@@ -428,12 +428,12 @@ test('It should send compressed JSON data when `global` is `true` :', async (t)
428
428
  }
429
429
  })
430
430
  const payload = zlib.gunzipSync(response.rawPayload)
431
- t.equal(payload.toString('utf-8'), JSON.stringify(json))
431
+ t.assert.equal(payload.toString('utf-8'), JSON.stringify(json))
432
432
  })
433
433
  })
434
434
 
435
- test('It should fallback to the default `gzip` encoding compression :', async (t) => {
436
- t.test('when `Accept-Encoding` request header value is set to `*`', async (t) => {
435
+ describe('It should fallback to the default `gzip` encoding compression :', async () => {
436
+ test('when `Accept-Encoding` request header value is set to `*`', async (t) => {
437
437
  t.plan(3)
438
438
 
439
439
  const fastify = Fastify()
@@ -454,12 +454,12 @@ test('It should fallback to the default `gzip` encoding compression :', async (t
454
454
  })
455
455
  const file = readFileSync('./package.json', 'utf8')
456
456
  const payload = zlib.gunzipSync(response.rawPayload)
457
- t.equal(response.headers.vary, 'accept-encoding')
458
- t.equal(response.headers['content-encoding'], 'gzip')
459
- t.equal(payload.toString('utf-8'), file)
457
+ t.assert.equal(response.headers.vary, 'accept-encoding')
458
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
459
+ t.assert.equal(payload.toString('utf-8'), file)
460
460
  })
461
461
 
462
- t.test('when `Accept-Encoding` request header value is set to multiple `*` directives', async (t) => {
462
+ test('when `Accept-Encoding` request header value is set to multiple `*` directives', async (t) => {
463
463
  t.plan(3)
464
464
 
465
465
  const fastify = Fastify()
@@ -480,14 +480,14 @@ test('It should fallback to the default `gzip` encoding compression :', async (t
480
480
  })
481
481
  const file = readFileSync('./package.json', 'utf8')
482
482
  const payload = zlib.gunzipSync(response.rawPayload)
483
- t.equal(response.headers.vary, 'accept-encoding')
484
- t.equal(response.headers['content-encoding'], 'gzip')
485
- t.equal(payload.toString('utf-8'), file)
483
+ t.assert.equal(response.headers.vary, 'accept-encoding')
484
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
485
+ t.assert.equal(payload.toString('utf-8'), file)
486
486
  })
487
487
  })
488
488
 
489
- test('When a custom `zlib` option is provided, it should compress data :`', async (t) => {
490
- t.test('using the custom `createBrotliCompress()` method', async (t) => {
489
+ describe('When a custom `zlib` option is provided, it should compress data :`', async () => {
490
+ test('using the custom `createBrotliCompress()` method', async (t) => {
491
491
  t.plan(5)
492
492
 
493
493
  let usedCustom = false
@@ -509,17 +509,17 @@ test('When a custom `zlib` option is provided, it should compress data :`', asyn
509
509
  'accept-encoding': 'br'
510
510
  }
511
511
  })
512
- t.equal(usedCustom, true)
512
+ t.assert.equal(usedCustom, true)
513
513
 
514
514
  const file = readFileSync('./package.json', 'utf8')
515
515
  const payload = zlib.brotliDecompressSync(response.rawPayload)
516
- t.equal(response.headers.vary, 'accept-encoding')
517
- t.equal(response.headers['content-encoding'], 'br')
518
- t.notOk(response.headers['content-length'], 'no content length')
519
- t.equal(payload.toString('utf-8'), file)
516
+ t.assert.equal(response.headers.vary, 'accept-encoding')
517
+ t.assert.equal(response.headers['content-encoding'], 'br')
518
+ t.assert.ok(!response.headers['content-length'], 'no content length')
519
+ t.assert.equal(payload.toString('utf-8'), file)
520
520
  })
521
521
 
522
- t.test('using the custom `createDeflate()` method', async (t) => {
522
+ test('using the custom `createDeflate()` method', async (t) => {
523
523
  t.plan(5)
524
524
 
525
525
  let usedCustom = false
@@ -541,17 +541,17 @@ test('When a custom `zlib` option is provided, it should compress data :`', asyn
541
541
  'accept-encoding': 'deflate'
542
542
  }
543
543
  })
544
- t.equal(usedCustom, true)
544
+ t.assert.equal(usedCustom, true)
545
545
 
546
546
  const file = readFileSync('./package.json', 'utf8')
547
547
  const payload = zlib.inflateSync(response.rawPayload)
548
- t.equal(response.headers.vary, 'accept-encoding')
549
- t.equal(response.headers['content-encoding'], 'deflate')
550
- t.notOk(response.headers['content-length'], 'no content length')
551
- t.equal(payload.toString('utf-8'), file)
548
+ t.assert.equal(response.headers.vary, 'accept-encoding')
549
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
550
+ t.assert.ok(!response.headers['content-length'], 'no content length')
551
+ t.assert.equal(payload.toString('utf-8'), file)
552
552
  })
553
553
 
554
- t.test('using the custom `createGzip()` method', async (t) => {
554
+ test('using the custom `createGzip()` method', async (t) => {
555
555
  t.plan(4)
556
556
 
557
557
  let usedCustom = false
@@ -573,18 +573,18 @@ test('When a custom `zlib` option is provided, it should compress data :`', asyn
573
573
  'accept-encoding': 'gzip'
574
574
  }
575
575
  })
576
- t.equal(usedCustom, true)
576
+ t.assert.equal(usedCustom, true)
577
577
 
578
578
  const file = readFileSync('./package.json', 'utf8')
579
579
  const payload = zlib.gunzipSync(response.rawPayload)
580
- t.equal(response.headers.vary, 'accept-encoding')
581
- t.equal(response.headers['content-encoding'], 'gzip')
582
- t.equal(payload.toString('utf-8'), file)
580
+ t.assert.equal(response.headers.vary, 'accept-encoding')
581
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
582
+ t.assert.equal(payload.toString('utf-8'), file)
583
583
  })
584
584
  })
585
585
 
586
- test('When a malformed custom `zlib` option is provided, it should compress data :', async (t) => {
587
- t.test('using the fallback default Node.js core `zlib.createBrotliCompress()` method', async (t) => {
586
+ describe('When a malformed custom `zlib` option is provided, it should compress data :', async () => {
587
+ test('using the fallback default Node.js core `zlib.createBrotliCompress()` method', async (t) => {
588
588
  t.plan(1)
589
589
 
590
590
  const fastify = Fastify()
@@ -608,10 +608,10 @@ test('When a malformed custom `zlib` option is provided, it should compress data
608
608
  }
609
609
  })
610
610
  const payload = zlib.brotliDecompressSync(response.rawPayload)
611
- t.equal(payload.toString('utf-8'), 'hello')
611
+ t.assert.equal(payload.toString('utf-8'), 'hello')
612
612
  })
613
613
 
614
- t.test('using the fallback default Node.js core `zlib.createDeflate()` method', async (t) => {
614
+ test('using the fallback default Node.js core `zlib.createDeflate()` method', async (t) => {
615
615
  t.plan(1)
616
616
 
617
617
  const fastify = Fastify()
@@ -635,10 +635,10 @@ test('When a malformed custom `zlib` option is provided, it should compress data
635
635
  }
636
636
  })
637
637
  const payload = zlib.inflateSync(response.rawPayload)
638
- t.equal(payload.toString('utf-8'), 'hello')
638
+ t.assert.equal(payload.toString('utf-8'), 'hello')
639
639
  })
640
640
 
641
- t.test('using the fallback default Node.js core `zlib.createGzip()` method', async (t) => {
641
+ test('using the fallback default Node.js core `zlib.createGzip()` method', async (t) => {
642
642
  t.plan(1)
643
643
 
644
644
  const fastify = Fastify()
@@ -662,12 +662,12 @@ test('When a malformed custom `zlib` option is provided, it should compress data
662
662
  }
663
663
  })
664
664
  const payload = zlib.gunzipSync(response.rawPayload)
665
- t.equal(payload.toString('utf-8'), 'hello')
665
+ t.assert.equal(payload.toString('utf-8'), 'hello')
666
666
  })
667
667
  })
668
668
 
669
- test('When `inflateIfDeflated` is `true` and `X-No-Compression` request header is `true` :', async (t) => {
670
- t.test('it should uncompress payloads using the deflate algorithm', async (t) => {
669
+ describe('When `inflateIfDeflated` is `true` and `X-No-Compression` request header is `true` :', async () => {
670
+ test('it should uncompress payloads using the deflate algorithm', async (t) => {
671
671
  t.plan(4)
672
672
 
673
673
  const fastify = Fastify()
@@ -685,13 +685,13 @@ test('When `inflateIfDeflated` is `true` and `X-No-Compression` request header i
685
685
  'x-no-compression': true
686
686
  }
687
687
  })
688
- t.equal(response.statusCode, 200)
689
- t.notOk(response.headers.vary)
690
- t.notOk(response.headers['content-encoding'])
691
- t.same(JSON.parse('' + response.payload), json)
688
+ t.assert.equal(response.statusCode, 200)
689
+ t.assert.ok(!response.headers.vary)
690
+ t.assert.ok(!response.headers['content-encoding'])
691
+ t.assert.deepEqual(JSON.parse('' + response.payload), json)
692
692
  })
693
693
 
694
- t.test('it should uncompress payloads using the gzip algorithm', async (t) => {
694
+ test('it should uncompress payloads using the gzip algorithm', async (t) => {
695
695
  t.plan(4)
696
696
 
697
697
  const fastify = Fastify()
@@ -709,10 +709,10 @@ test('When `inflateIfDeflated` is `true` and `X-No-Compression` request header i
709
709
  'x-no-compression': true
710
710
  }
711
711
  })
712
- t.equal(response.statusCode, 200)
713
- t.notOk(response.headers.vary)
714
- t.notOk(response.headers['content-encoding'])
715
- t.same(JSON.parse('' + response.payload), json)
712
+ t.assert.equal(response.statusCode, 200)
713
+ t.assert.ok(!response.headers.vary)
714
+ t.assert.ok(!response.headers['content-encoding'])
715
+ t.assert.deepEqual(JSON.parse('' + response.payload), json)
716
716
  })
717
717
  })
718
718
 
@@ -738,16 +738,16 @@ test('it should not uncompress payloads using the zip algorithm', async (t) => {
738
738
  'x-no-compression': true
739
739
  }
740
740
  })
741
- t.equal(response.statusCode, 200)
742
- t.notOk(response.headers.vary)
743
- t.notOk(response.headers['content-encoding'])
744
- t.same(response.rawPayload, fileBuffer)
745
- t.equal(response.payload, fileBuffer.toString('utf-8'))
741
+ t.assert.equal(response.statusCode, 200)
742
+ t.assert.ok(!response.headers.vary)
743
+ t.assert.ok(!response.headers['content-encoding'])
744
+ t.assert.deepEqual(response.rawPayload, fileBuffer)
745
+ t.assert.equal(response.payload, fileBuffer.toString('utf-8'))
746
746
  })
747
747
 
748
- test('It should not compress :', async (t) => {
749
- t.test('Using `reply.compress()` :', async (t) => {
750
- t.test('when payload length is smaller than the `threshold` defined value', async (t) => {
748
+ describe('It should not compress :', async () => {
749
+ describe('Using `reply.compress()` :', async () => {
750
+ test('when payload length is smaller than the `threshold` defined value', async (t) => {
751
751
  t.plan(4)
752
752
 
753
753
  const fastify = Fastify()
@@ -766,13 +766,13 @@ test('It should not compress :', async (t) => {
766
766
  'accept-encoding': 'deflate'
767
767
  }
768
768
  })
769
- t.equal(response.statusCode, 200)
770
- t.notOk(response.headers.vary)
771
- t.notOk(response.headers['content-encoding'])
772
- t.equal(response.payload, 'a message')
769
+ t.assert.equal(response.statusCode, 200)
770
+ t.assert.ok(!response.headers.vary)
771
+ t.assert.ok(!response.headers['content-encoding'])
772
+ t.assert.equal(response.payload, 'a message')
773
773
  })
774
774
 
775
- t.test('when `customTypes` is set and does not match `Content-Type` reply header or `mime-db`', async (t) => {
775
+ test('when `customTypes` is set and does not match `Content-Type` reply header or `mime-db`', async (t) => {
776
776
  t.plan(3)
777
777
 
778
778
  const fastify = Fastify()
@@ -791,12 +791,12 @@ test('It should not compress :', async (t) => {
791
791
  'accept-encoding': 'gzip'
792
792
  }
793
793
  })
794
- t.notOk(response.headers.vary, 'accept-encoding')
795
- t.notOk(response.headers['content-encoding'])
796
- t.equal(response.statusCode, 200)
794
+ t.assert.ok(!response.headers.vary, 'accept-encoding')
795
+ t.assert.ok(!response.headers['content-encoding'])
796
+ t.assert.equal(response.statusCode, 200)
797
797
  })
798
798
 
799
- t.test('when `customTypes` is a function and returns false on the provided `Content-Type` reply header`', async (t) => {
799
+ test('when `customTypes` is a function and returns false on the provided `Content-Type` reply header`', async (t) => {
800
800
  t.plan(3)
801
801
 
802
802
  const fastify = Fastify()
@@ -815,12 +815,12 @@ test('It should not compress :', async (t) => {
815
815
  'accept-encoding': 'gzip'
816
816
  }
817
817
  })
818
- t.notOk(response.headers.vary)
819
- t.notOk(response.headers['content-encoding'])
820
- t.equal(response.statusCode, 200)
818
+ t.assert.ok(!response.headers.vary)
819
+ t.assert.ok(!response.headers['content-encoding'])
820
+ t.assert.equal(response.statusCode, 200)
821
821
  })
822
822
 
823
- t.test('when `X-No-Compression` request header is `true`', async (t) => {
823
+ test('when `X-No-Compression` request header is `true`', async (t) => {
824
824
  t.plan(4)
825
825
 
826
826
  const fastify = Fastify()
@@ -838,13 +838,13 @@ test('It should not compress :', async (t) => {
838
838
  'x-no-compression': true
839
839
  }
840
840
  })
841
- t.equal(response.statusCode, 200)
842
- t.notOk(response.headers.vary)
843
- t.notOk(response.headers['content-encoding'])
844
- t.same(JSON.parse(response.payload), json)
841
+ t.assert.equal(response.statusCode, 200)
842
+ t.assert.ok(!response.headers.vary)
843
+ t.assert.ok(!response.headers['content-encoding'])
844
+ t.assert.deepEqual(JSON.parse(response.payload), json)
845
845
  })
846
846
 
847
- t.test('when `Content-Type` reply header is not set and the content is not detected as a compressible type', async (t) => {
847
+ test('when `Content-Type` reply header is not set and the content is not detected as a compressible type', async (t) => {
848
848
  t.plan(3)
849
849
 
850
850
  const fastify = Fastify()
@@ -868,12 +868,12 @@ test('It should not compress :', async (t) => {
868
868
  'accept-encoding': 'identity'
869
869
  }
870
870
  })
871
- t.notOk(response.headers.vary)
872
- t.notOk(response.headers['content-encoding'])
873
- t.equal(response.payload, JSON.stringify(json))
871
+ t.assert.ok(!response.headers.vary)
872
+ t.assert.ok(!response.headers['content-encoding'])
873
+ t.assert.equal(response.payload, JSON.stringify(json))
874
874
  })
875
875
 
876
- t.test('when `Content-Type` reply header is a mime type with undefined compressible values', async (t) => {
876
+ test('when `Content-Type` reply header is a mime type with undefined compressible values', async (t) => {
877
877
  t.plan(4)
878
878
 
879
879
  const fastify = Fastify()
@@ -892,13 +892,13 @@ test('It should not compress :', async (t) => {
892
892
  'accept-encoding': 'gzip, deflate, br'
893
893
  }
894
894
  })
895
- t.equal(response.statusCode, 200)
896
- t.notOk(response.headers.vary)
897
- t.notOk(response.headers['content-encoding'])
898
- t.equal(response.payload, 'hello')
895
+ t.assert.equal(response.statusCode, 200)
896
+ t.assert.ok(!response.headers.vary)
897
+ t.assert.ok(!response.headers['content-encoding'])
898
+ t.assert.equal(response.payload, 'hello')
899
899
  })
900
900
 
901
- t.test('when `Content-Type` reply header value is `text/event-stream`', async (t) => {
901
+ test('when `Content-Type` reply header value is `text/event-stream`', async (t) => {
902
902
  t.plan(4)
903
903
 
904
904
  const fastify = Fastify()
@@ -920,13 +920,13 @@ test('It should not compress :', async (t) => {
920
920
  url: '/',
921
921
  method: 'GET'
922
922
  })
923
- t.equal(response.statusCode, 200)
924
- t.notOk(response.headers.vary)
925
- t.notOk(response.headers['content-encoding'])
926
- t.same(response.payload, 'event: open\n\nevent: change\ndata: schema\n\n')
923
+ t.assert.equal(response.statusCode, 200)
924
+ t.assert.ok(!response.headers.vary)
925
+ t.assert.ok(!response.headers['content-encoding'])
926
+ t.assert.deepEqual(response.payload, 'event: open\n\nevent: change\ndata: schema\n\n')
927
927
  })
928
928
 
929
- t.test('when `Content-Type` reply header value is an invalid type', async (t) => {
929
+ test('when `Content-Type` reply header value is an invalid type', async (t) => {
930
930
  t.plan(4)
931
931
 
932
932
  const fastify = Fastify()
@@ -945,13 +945,13 @@ test('It should not compress :', async (t) => {
945
945
  'accept-encoding': 'deflate'
946
946
  }
947
947
  })
948
- t.equal(response.statusCode, 200)
949
- t.notOk(response.headers.vary)
950
- t.notOk(response.headers['content-encoding'])
951
- t.equal(response.payload, 'a message')
948
+ t.assert.equal(response.statusCode, 200)
949
+ t.assert.ok(!response.headers.vary)
950
+ t.assert.ok(!response.headers['content-encoding'])
951
+ t.assert.equal(response.payload, 'a message')
952
952
  })
953
953
 
954
- t.test('when `Accept-Encoding` request header is missing', async (t) => {
954
+ test('when `Accept-Encoding` request header is missing', async (t) => {
955
955
  t.plan(3)
956
956
 
957
957
  const fastify = Fastify()
@@ -967,12 +967,12 @@ test('It should not compress :', async (t) => {
967
967
  url: '/',
968
968
  method: 'GET'
969
969
  })
970
- t.equal(response.statusCode, 200)
971
- t.notOk(response.headers.vary)
972
- t.notOk(response.headers['content-encoding'])
970
+ t.assert.equal(response.statusCode, 200)
971
+ t.assert.ok(!response.headers.vary)
972
+ t.assert.ok(!response.headers['content-encoding'])
973
973
  })
974
974
 
975
- t.test('when `Accept-Encoding` request header is set to `identity`', async (t) => {
975
+ test('when `Accept-Encoding` request header is set to `identity`', async (t) => {
976
976
  t.plan(3)
977
977
 
978
978
  const fastify = Fastify()
@@ -990,12 +990,12 @@ test('It should not compress :', async (t) => {
990
990
  }
991
991
  })
992
992
  const payload = JSON.parse(response.payload)
993
- t.notOk(response.headers.vary)
994
- t.notOk(response.headers['content-encoding'])
995
- t.same({ hello: 'world' }, payload)
993
+ t.assert.ok(!response.headers.vary)
994
+ t.assert.ok(!response.headers['content-encoding'])
995
+ t.assert.deepEqual({ hello: 'world' }, payload)
996
996
  })
997
997
 
998
- t.test('when `Accept-Encoding` request header value is not supported', async (t) => {
998
+ test('when `Accept-Encoding` request header value is not supported', async (t) => {
999
999
  t.plan(3)
1000
1000
 
1001
1001
  const fastify = Fastify()
@@ -1015,12 +1015,12 @@ test('It should not compress :', async (t) => {
1015
1015
  }
1016
1016
  })
1017
1017
  const file = readFileSync('./package.json', 'utf8')
1018
- t.equal(response.statusCode, 200)
1019
- t.notOk(response.headers.vary)
1020
- t.equal(response.payload, file)
1018
+ t.assert.equal(response.statusCode, 200)
1019
+ t.assert.ok(!response.headers.vary)
1020
+ t.assert.equal(response.payload, file)
1021
1021
  })
1022
1022
 
1023
- t.test('when `Accept-Encoding` request header value is not supported (with quality value)', async (t) => {
1023
+ test('when `Accept-Encoding` request header value is not supported (with quality value)', async (t) => {
1024
1024
  t.plan(3)
1025
1025
 
1026
1026
  const fastify = Fastify()
@@ -1040,12 +1040,12 @@ test('It should not compress :', async (t) => {
1040
1040
  }
1041
1041
  })
1042
1042
  const file = readFileSync('./package.json', 'utf8')
1043
- t.equal(response.statusCode, 200)
1044
- t.notOk(response.headers.vary)
1045
- t.equal(response.payload, file)
1043
+ t.assert.equal(response.statusCode, 200)
1044
+ t.assert.ok(!response.headers.vary)
1045
+ t.assert.equal(response.payload, file)
1046
1046
  })
1047
1047
 
1048
- t.test('when `Accept-Encoding` request header is set to `identity and `inflateIfDeflated` is `true``', async (t) => {
1048
+ test('when `Accept-Encoding` request header is set to `identity and `inflateIfDeflated` is `true``', async (t) => {
1049
1049
  t.plan(3)
1050
1050
 
1051
1051
  const fastify = Fastify()
@@ -1063,14 +1063,14 @@ test('It should not compress :', async (t) => {
1063
1063
  }
1064
1064
  })
1065
1065
  const payload = JSON.parse(response.payload)
1066
- t.notOk(response.headers.vary)
1067
- t.notOk(response.headers['content-encoding'])
1068
- t.same({ hello: 'world' }, payload)
1066
+ t.assert.ok(!response.headers.vary)
1067
+ t.assert.ok(!response.headers['content-encoding'])
1068
+ t.assert.deepEqual({ hello: 'world' }, payload)
1069
1069
  })
1070
1070
  })
1071
1071
 
1072
- t.test('Using `onSend` hook :', async (t) => {
1073
- t.test('when there is no payload', async (t) => {
1072
+ describe('Using `onSend` hook :', async () => {
1073
+ test('when there is no payload', async (t) => {
1074
1074
  t.plan(4)
1075
1075
 
1076
1076
  const fastify = Fastify()
@@ -1087,13 +1087,13 @@ test('It should not compress :', async (t) => {
1087
1087
  'accept-encoding': 'gzip'
1088
1088
  }
1089
1089
  })
1090
- t.equal(response.statusCode, 200)
1091
- t.notOk(response.headers.vary)
1092
- t.notOk(response.headers['content-encoding'])
1093
- t.equal(response.payload, '')
1090
+ t.assert.equal(response.statusCode, 200)
1091
+ t.assert.ok(!response.headers.vary)
1092
+ t.assert.ok(!response.headers['content-encoding'])
1093
+ t.assert.equal(response.payload, '')
1094
1094
  })
1095
1095
 
1096
- t.test('when payload length is smaller than the `threshold` defined value', async (t) => {
1096
+ test('when payload length is smaller than the `threshold` defined value', async (t) => {
1097
1097
  t.plan(4)
1098
1098
 
1099
1099
  const fastify = Fastify()
@@ -1112,13 +1112,13 @@ test('It should not compress :', async (t) => {
1112
1112
  'accept-encoding': 'deflate'
1113
1113
  }
1114
1114
  })
1115
- t.equal(response.statusCode, 200)
1116
- t.notOk(response.headers.vary)
1117
- t.notOk(response.headers['content-encoding'])
1118
- t.equal(response.payload, 'a message')
1115
+ t.assert.equal(response.statusCode, 200)
1116
+ t.assert.ok(!response.headers.vary)
1117
+ t.assert.ok(!response.headers['content-encoding'])
1118
+ t.assert.equal(response.payload, 'a message')
1119
1119
  })
1120
1120
 
1121
- t.test('when `customTypes` is set and does not match `Content-Type` reply header or `mime-db`', async (t) => {
1121
+ test('when `customTypes` is set and does not match `Content-Type` reply header or `mime-db`', async (t) => {
1122
1122
  t.plan(3)
1123
1123
 
1124
1124
  const fastify = Fastify()
@@ -1137,12 +1137,12 @@ test('It should not compress :', async (t) => {
1137
1137
  'accept-encoding': 'gzip'
1138
1138
  }
1139
1139
  })
1140
- t.notOk(response.headers.vary)
1141
- t.notOk(response.headers['content-encoding'])
1142
- t.equal(response.statusCode, 200)
1140
+ t.assert.ok(!response.headers.vary)
1141
+ t.assert.ok(!response.headers['content-encoding'])
1142
+ t.assert.equal(response.statusCode, 200)
1143
1143
  })
1144
1144
 
1145
- t.test('when `X-No-Compression` request header is `true`', async (t) => {
1145
+ test('when `X-No-Compression` request header is `true`', async (t) => {
1146
1146
  t.plan(4)
1147
1147
 
1148
1148
  const fastify = Fastify()
@@ -1160,13 +1160,13 @@ test('It should not compress :', async (t) => {
1160
1160
  'x-no-compression': true
1161
1161
  }
1162
1162
  })
1163
- t.equal(response.statusCode, 200)
1164
- t.notOk(response.headers.vary)
1165
- t.notOk(response.headers['content-encoding'])
1166
- t.same(JSON.parse(response.payload), json)
1163
+ t.assert.equal(response.statusCode, 200)
1164
+ t.assert.ok(!response.headers.vary)
1165
+ t.assert.ok(!response.headers['content-encoding'])
1166
+ t.assert.deepEqual(JSON.parse(response.payload), json)
1167
1167
  })
1168
1168
 
1169
- t.test('when `Content-Type` reply header is not set and the content is not detected as a compressible type', async (t) => {
1169
+ test('when `Content-Type` reply header is not set and the content is not detected as a compressible type', async (t) => {
1170
1170
  t.plan(3)
1171
1171
 
1172
1172
  const fastify = Fastify()
@@ -1190,12 +1190,12 @@ test('It should not compress :', async (t) => {
1190
1190
  'accept-encoding': 'identity'
1191
1191
  }
1192
1192
  })
1193
- t.notOk(response.headers.vary)
1194
- t.notOk(response.headers['content-encoding'])
1195
- t.equal(response.payload, JSON.stringify(json))
1193
+ t.assert.ok(!response.headers.vary)
1194
+ t.assert.ok(!response.headers['content-encoding'])
1195
+ t.assert.equal(response.payload, JSON.stringify(json))
1196
1196
  })
1197
1197
 
1198
- t.test('when `Content-Type` reply header is a mime type with undefined compressible values', async (t) => {
1198
+ test('when `Content-Type` reply header is a mime type with undefined compressible values', async (t) => {
1199
1199
  t.plan(4)
1200
1200
 
1201
1201
  const fastify = Fastify()
@@ -1214,13 +1214,13 @@ test('It should not compress :', async (t) => {
1214
1214
  'accept-encoding': 'gzip, deflate, br'
1215
1215
  }
1216
1216
  })
1217
- t.equal(response.statusCode, 200)
1218
- t.notOk(response.headers.vary)
1219
- t.notOk(response.headers['content-encoding'])
1220
- t.equal(response.payload, 'hello')
1217
+ t.assert.equal(response.statusCode, 200)
1218
+ t.assert.ok(!response.headers.vary)
1219
+ t.assert.ok(!response.headers['content-encoding'])
1220
+ t.assert.equal(response.payload, 'hello')
1221
1221
  })
1222
1222
 
1223
- t.test('when `Content-Type` reply header value is `text/event-stream`', async (t) => {
1223
+ test('when `Content-Type` reply header value is `text/event-stream`', async (t) => {
1224
1224
  t.plan(4)
1225
1225
 
1226
1226
  const fastify = Fastify()
@@ -1242,13 +1242,13 @@ test('It should not compress :', async (t) => {
1242
1242
  url: '/',
1243
1243
  method: 'GET'
1244
1244
  })
1245
- t.equal(response.statusCode, 200)
1246
- t.notOk(response.headers.vary)
1247
- t.notOk(response.headers['content-encoding'])
1248
- t.same(response.payload, 'event: open\n\nevent: change\ndata: schema\n\n')
1245
+ t.assert.equal(response.statusCode, 200)
1246
+ t.assert.ok(!response.headers.vary)
1247
+ t.assert.ok(!response.headers['content-encoding'])
1248
+ t.assert.deepEqual(response.payload, 'event: open\n\nevent: change\ndata: schema\n\n')
1249
1249
  })
1250
1250
 
1251
- t.test('when `Content-Type` reply header value is an invalid type', async (t) => {
1251
+ test('when `Content-Type` reply header value is an invalid type', async (t) => {
1252
1252
  t.plan(4)
1253
1253
 
1254
1254
  const fastify = Fastify()
@@ -1267,13 +1267,13 @@ test('It should not compress :', async (t) => {
1267
1267
  'accept-encoding': 'deflate'
1268
1268
  }
1269
1269
  })
1270
- t.equal(response.statusCode, 200)
1271
- t.notOk(response.headers.vary)
1272
- t.notOk(response.headers['content-encoding'])
1273
- t.equal(response.payload, 'a message')
1270
+ t.assert.equal(response.statusCode, 200)
1271
+ t.assert.ok(!response.headers.vary)
1272
+ t.assert.ok(!response.headers['content-encoding'])
1273
+ t.assert.equal(response.payload, 'a message')
1274
1274
  })
1275
1275
 
1276
- t.test('when `Accept-Encoding` request header is missing', async (t) => {
1276
+ test('when `Accept-Encoding` request header is missing', async (t) => {
1277
1277
  t.plan(3)
1278
1278
 
1279
1279
  const fastify = Fastify()
@@ -1289,12 +1289,12 @@ test('It should not compress :', async (t) => {
1289
1289
  url: '/',
1290
1290
  method: 'GET'
1291
1291
  })
1292
- t.equal(response.statusCode, 200)
1293
- t.notOk(response.headers.vary)
1294
- t.notOk(response.headers['content-encoding'])
1292
+ t.assert.equal(response.statusCode, 200)
1293
+ t.assert.ok(!response.headers.vary)
1294
+ t.assert.ok(!response.headers['content-encoding'])
1295
1295
  })
1296
1296
 
1297
- t.test('when `Accept-Encoding` request header is set to `identity`', async (t) => {
1297
+ test('when `Accept-Encoding` request header is set to `identity`', async (t) => {
1298
1298
  t.plan(3)
1299
1299
 
1300
1300
  const fastify = Fastify()
@@ -1312,12 +1312,12 @@ test('It should not compress :', async (t) => {
1312
1312
  }
1313
1313
  })
1314
1314
  const payload = JSON.parse(response.payload)
1315
- t.notOk(response.headers.vary)
1316
- t.notOk(response.headers['content-encoding'])
1317
- t.same({ hello: 'world' }, payload)
1315
+ t.assert.ok(!response.headers.vary)
1316
+ t.assert.ok(!response.headers['content-encoding'])
1317
+ t.assert.deepEqual({ hello: 'world' }, payload)
1318
1318
  })
1319
1319
 
1320
- t.test('when `Accept-Encoding` request header value is not supported', async (t) => {
1320
+ test('when `Accept-Encoding` request header value is not supported', async (t) => {
1321
1321
  t.plan(2)
1322
1322
 
1323
1323
  const fastify = Fastify()
@@ -1336,11 +1336,11 @@ test('It should not compress :', async (t) => {
1336
1336
  'accept-encoding': 'invalid'
1337
1337
  }
1338
1338
  })
1339
- t.equal(response.statusCode, 200)
1340
- t.equal(response.payload, 'something')
1339
+ t.assert.equal(response.statusCode, 200)
1340
+ t.assert.equal(response.payload, 'something')
1341
1341
  })
1342
1342
 
1343
- t.test('when `Accept-Encoding` request header value is not supported (with quality value)', async (t) => {
1343
+ test('when `Accept-Encoding` request header value is not supported (with quality value)', async (t) => {
1344
1344
  t.plan(3)
1345
1345
 
1346
1346
  const fastify = Fastify()
@@ -1360,12 +1360,12 @@ test('It should not compress :', async (t) => {
1360
1360
  }
1361
1361
  })
1362
1362
  const file = readFileSync('./package.json', 'utf8')
1363
- t.equal(response.statusCode, 200)
1364
- t.notOk(response.headers.vary)
1365
- t.equal(response.payload, file)
1363
+ t.assert.equal(response.statusCode, 200)
1364
+ t.assert.ok(!response.headers.vary)
1365
+ t.assert.equal(response.payload, file)
1366
1366
  })
1367
1367
 
1368
- t.test('when `Accept-Encoding` request header is set to `identity and `inflateIfDeflated` is `true``', async (t) => {
1368
+ test('when `Accept-Encoding` request header is set to `identity and `inflateIfDeflated` is `true``', async (t) => {
1369
1369
  t.plan(3)
1370
1370
 
1371
1371
  const fastify = Fastify()
@@ -1383,15 +1383,15 @@ test('It should not compress :', async (t) => {
1383
1383
  }
1384
1384
  })
1385
1385
  const payload = JSON.parse(response.payload)
1386
- t.notOk(response.headers.vary)
1387
- t.notOk(response.headers['content-encoding'])
1388
- t.same({ hello: 'world' }, payload)
1386
+ t.assert.ok(!response.headers.vary)
1387
+ t.assert.ok(!response.headers['content-encoding'])
1388
+ t.assert.deepEqual({ hello: 'world' }, payload)
1389
1389
  })
1390
1390
  })
1391
1391
  })
1392
1392
 
1393
- test('It should not double-compress :', async (t) => {
1394
- t.test('when using `reply.compress()` to send an already deflated Stream', async (t) => {
1393
+ describe('It should not double-compress :', async () => {
1394
+ test('when using `reply.compress()` to send an already deflated Stream', async (t) => {
1395
1395
  t.plan(3)
1396
1396
 
1397
1397
  const fastify = Fastify()
@@ -1414,12 +1414,12 @@ test('It should not double-compress :', async (t) => {
1414
1414
  })
1415
1415
  const file = readFileSync('./package.json', 'utf8')
1416
1416
  const payload = zlib.inflateSync(response.rawPayload)
1417
- t.equal(response.headers.vary, 'accept-encoding')
1418
- t.equal(response.headers['content-encoding'], 'deflate')
1419
- t.equal(payload.toString('utf-8'), file)
1417
+ t.assert.equal(response.headers.vary, 'accept-encoding')
1418
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
1419
+ t.assert.equal(payload.toString('utf-8'), file)
1420
1420
  })
1421
1421
 
1422
- t.test('when using `reply.compress()` to send an already gzipped Stream', async (t) => {
1422
+ test('when using `reply.compress()` to send an already gzipped Stream', async (t) => {
1423
1423
  t.plan(3)
1424
1424
 
1425
1425
  const fastify = Fastify()
@@ -1442,12 +1442,12 @@ test('It should not double-compress :', async (t) => {
1442
1442
  })
1443
1443
  const file = readFileSync('./package.json', 'utf8')
1444
1444
  const payload = zlib.gunzipSync(response.rawPayload)
1445
- t.equal(response.headers.vary, 'accept-encoding')
1446
- t.equal(response.headers['content-encoding'], 'gzip')
1447
- t.equal(payload.toString('utf-8'), file)
1445
+ t.assert.equal(response.headers.vary, 'accept-encoding')
1446
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
1447
+ t.assert.equal(payload.toString('utf-8'), file)
1448
1448
  })
1449
1449
 
1450
- t.test('when using `onSend` hook to send an already brotli compressed Stream', async (t) => {
1450
+ test('when using `onSend` hook to send an already brotli compressed Stream', async (t) => {
1451
1451
  t.plan(4)
1452
1452
 
1453
1453
  const fastify = Fastify()
@@ -1472,13 +1472,13 @@ test('It should not double-compress :', async (t) => {
1472
1472
  }
1473
1473
  })
1474
1474
  const payload = zlib.brotliDecompressSync(response.rawPayload)
1475
- t.notOk(response.headers.vary)
1476
- t.equal(response.headers['content-encoding'], 'br')
1477
- t.equal(response.headers['content-length'], response.rawPayload.length.toString())
1478
- t.equal(payload.toString('utf-8'), file)
1475
+ t.assert.ok(!response.headers.vary)
1476
+ t.assert.equal(response.headers['content-encoding'], 'br')
1477
+ t.assert.equal(response.headers['content-length'], response.rawPayload.length.toString())
1478
+ t.assert.equal(payload.toString('utf-8'), file)
1479
1479
  })
1480
1480
 
1481
- t.test('when using `onSend` hook to send an already deflated Stream', async (t) => {
1481
+ test('when using `onSend` hook to send an already deflated Stream', async (t) => {
1482
1482
  t.plan(4)
1483
1483
 
1484
1484
  const fastify = Fastify()
@@ -1503,13 +1503,13 @@ test('It should not double-compress :', async (t) => {
1503
1503
  }
1504
1504
  })
1505
1505
  const payload = zlib.inflateSync(response.rawPayload)
1506
- t.notOk(response.headers.vary)
1507
- t.equal(response.headers['content-encoding'], 'deflate')
1508
- t.equal(response.headers['content-length'], response.rawPayload.length.toString())
1509
- t.equal(payload.toString('utf-8'), file)
1506
+ t.assert.ok(!response.headers.vary)
1507
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
1508
+ t.assert.equal(response.headers['content-length'], response.rawPayload.length.toString())
1509
+ t.assert.equal(payload.toString('utf-8'), file)
1510
1510
  })
1511
1511
 
1512
- t.test('when using `onSend` hook to send an already gzipped Stream', async (t) => {
1512
+ test('when using `onSend` hook to send an already gzipped Stream', async (t) => {
1513
1513
  t.plan(4)
1514
1514
 
1515
1515
  const fastify = Fastify()
@@ -1534,16 +1534,16 @@ test('It should not double-compress :', async (t) => {
1534
1534
  }
1535
1535
  })
1536
1536
  const payload = zlib.gunzipSync(response.rawPayload)
1537
- t.notOk(response.headers.vary)
1538
- t.equal(response.headers['content-encoding'], 'gzip')
1539
- t.equal(response.headers['content-length'], response.rawPayload.length.toString())
1540
- t.equal(payload.toString('utf-8'), file)
1537
+ t.assert.ok(!response.headers.vary)
1538
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
1539
+ t.assert.equal(response.headers['content-length'], response.rawPayload.length.toString())
1540
+ t.assert.equal(payload.toString('utf-8'), file)
1541
1541
  })
1542
1542
  })
1543
1543
 
1544
- test('It should not compress Stream data and add a `Content-Encoding` reply header :', async (t) => {
1545
- t.test('Using `onSend` hook if `Accept-Encoding` request header value is `identity`', async (t) => {
1546
- t.test('when `inflateIfDeflated` is `true` and `encodings` is not set', async (t) => {
1544
+ describe('It should not compress Stream data and add a `Content-Encoding` reply header :', async () => {
1545
+ describe('Using `onSend` hook if `Accept-Encoding` request header value is `identity`', async () => {
1546
+ test('when `inflateIfDeflated` is `true` and `encodings` is not set', async (t) => {
1547
1547
  t.plan(4)
1548
1548
 
1549
1549
  const fastify = Fastify()
@@ -1563,13 +1563,13 @@ test('It should not compress Stream data and add a `Content-Encoding` reply head
1563
1563
  }
1564
1564
  })
1565
1565
  const file = readFileSync('./package.json', 'utf8')
1566
- t.equal(response.statusCode, 200)
1567
- t.notOk(response.headers.vary)
1568
- t.equal(response.headers['content-encoding'], 'identity')
1569
- t.equal(file, response.payload)
1566
+ t.assert.equal(response.statusCode, 200)
1567
+ t.assert.ok(!response.headers.vary)
1568
+ t.assert.equal(response.headers['content-encoding'], 'identity')
1569
+ t.assert.equal(file, response.payload)
1570
1570
  })
1571
1571
 
1572
- t.test('when `inflateIfDeflated` is `true` and `encodings` is set', async (t) => {
1572
+ test('when `inflateIfDeflated` is `true` and `encodings` is set', async (t) => {
1573
1573
  t.plan(4)
1574
1574
 
1575
1575
  const fastify = Fastify()
@@ -1592,15 +1592,15 @@ test('It should not compress Stream data and add a `Content-Encoding` reply head
1592
1592
  }
1593
1593
  })
1594
1594
  const file = readFileSync('./package.json', 'utf-8')
1595
- t.equal(response.statusCode, 200)
1596
- t.notOk(response.headers.vary)
1597
- t.equal(response.headers['content-encoding'], 'identity')
1598
- t.same(response.payload, file)
1595
+ t.assert.equal(response.statusCode, 200)
1596
+ t.assert.ok(!response.headers.vary)
1597
+ t.assert.equal(response.headers['content-encoding'], 'identity')
1598
+ t.assert.deepEqual(response.payload, file)
1599
1599
  })
1600
1600
  })
1601
1601
 
1602
- t.test('Using `reply.compress()` if `Accept-Encoding` request header value is `identity`', async (t) => {
1603
- t.test('when `inflateIfDeflated` is `true` and `encodings` is not set', async (t) => {
1602
+ describe('Using `reply.compress()` if `Accept-Encoding` request header value is `identity`', async () => {
1603
+ test('when `inflateIfDeflated` is `true` and `encodings` is not set', async (t) => {
1604
1604
  t.plan(4)
1605
1605
 
1606
1606
  const fastify = Fastify()
@@ -1620,13 +1620,13 @@ test('It should not compress Stream data and add a `Content-Encoding` reply head
1620
1620
  }
1621
1621
  })
1622
1622
  const file = readFileSync('./package.json', 'utf8')
1623
- t.equal(response.statusCode, 200)
1624
- t.notOk(response.headers.vary)
1625
- t.equal(response.headers['content-encoding'], 'identity')
1626
- t.equal(file, response.payload)
1623
+ t.assert.equal(response.statusCode, 200)
1624
+ t.assert.ok(!response.headers.vary)
1625
+ t.assert.equal(response.headers['content-encoding'], 'identity')
1626
+ t.assert.equal(file, response.payload)
1627
1627
  })
1628
1628
 
1629
- t.test('when `inflateIfDeflated` is `true` and `encodings` is set', async (t) => {
1629
+ test('when `inflateIfDeflated` is `true` and `encodings` is set', async (t) => {
1630
1630
  t.plan(4)
1631
1631
 
1632
1632
  const fastify = Fastify()
@@ -1649,10 +1649,10 @@ test('It should not compress Stream data and add a `Content-Encoding` reply head
1649
1649
  }
1650
1650
  })
1651
1651
  const file = readFileSync('./package.json', 'utf-8')
1652
- t.equal(response.statusCode, 200)
1653
- t.notOk(response.headers.vary)
1654
- t.equal(response.headers['content-encoding'], 'identity')
1655
- t.same(response.payload, file)
1652
+ t.assert.equal(response.statusCode, 200)
1653
+ t.assert.ok(!response.headers.vary)
1654
+ t.assert.equal(response.headers['content-encoding'], 'identity')
1655
+ t.assert.deepEqual(response.payload, file)
1656
1656
  })
1657
1657
  })
1658
1658
  })
@@ -1685,10 +1685,10 @@ test('It should return a serialized payload when `inflateIfDeflated` is `true` a
1685
1685
  'x-no-compression': true
1686
1686
  }
1687
1687
  })
1688
- t.equal(one.statusCode, 200)
1689
- t.notOk(one.headers.vary)
1690
- t.notOk(one.headers['content-encoding'])
1691
- t.same(JSON.parse(one.payload), json)
1688
+ t.assert.equal(one.statusCode, 200)
1689
+ t.assert.ok(!one.headers.vary)
1690
+ t.assert.ok(!one.headers['content-encoding'])
1691
+ t.assert.deepEqual(JSON.parse(one.payload), json)
1692
1692
 
1693
1693
  const two = await fastify.inject({
1694
1694
  url: '/two',
@@ -1697,10 +1697,10 @@ test('It should return a serialized payload when `inflateIfDeflated` is `true` a
1697
1697
  'x-no-compression': true
1698
1698
  }
1699
1699
  })
1700
- t.equal(two.statusCode, 200)
1701
- t.notOk(two.headers.vary)
1702
- t.notOk(two.headers['content-encoding'])
1703
- t.equal(two.payload, compressedBufferPayload.toString())
1700
+ t.assert.equal(two.statusCode, 200)
1701
+ t.assert.ok(!two.headers.vary)
1702
+ t.assert.ok(!two.headers['content-encoding'])
1703
+ t.assert.equal(two.payload, compressedBufferPayload.toString())
1704
1704
  })
1705
1705
 
1706
1706
  test('It should close the stream', async (t) => {
@@ -1713,7 +1713,7 @@ test('It should close the stream', async (t) => {
1713
1713
  const closed = once(stream, 'close')
1714
1714
 
1715
1715
  fastify.get('/', (request, reply) => {
1716
- stream.on('close', () => t.ok('stream closed'))
1716
+ stream.on('close', () => t.assert.ok('stream closed'))
1717
1717
 
1718
1718
  reply
1719
1719
  .type('text/plain')
@@ -1726,8 +1726,8 @@ test('It should close the stream', async (t) => {
1726
1726
  })
1727
1727
 
1728
1728
  const file = readFileSync('./package.json', 'utf8')
1729
- t.equal(response.statusCode, 200)
1730
- t.equal(file, response.payload)
1729
+ t.assert.equal(response.statusCode, 200)
1730
+ t.assert.equal(file, response.payload)
1731
1731
  await closed
1732
1732
  })
1733
1733
 
@@ -1772,11 +1772,11 @@ test('It should log an existing error with stream onEnd handler', async (t) => {
1772
1772
  'accept-encoding': 'gzip'
1773
1773
  }
1774
1774
  })
1775
- t.equal(actual.msg, expect.message)
1775
+ t.assert.equal(actual.msg, expect.message)
1776
1776
  })
1777
1777
 
1778
- test('It should support stream1 :', async (t) => {
1779
- t.test('when using `reply.compress()`', async (t) => {
1778
+ describe('It should support stream1 :', async () => {
1779
+ test('when using `reply.compress()`', async (t) => {
1780
1780
  t.plan(3)
1781
1781
 
1782
1782
  const fastify = Fastify()
@@ -1801,12 +1801,12 @@ test('It should support stream1 :', async (t) => {
1801
1801
  }
1802
1802
  })
1803
1803
  const payload = zlib.gunzipSync(response.rawPayload)
1804
- t.equal(response.headers.vary, 'accept-encoding')
1805
- t.equal(response.headers['content-encoding'], 'gzip')
1806
- t.same(JSON.parse(payload.toString()), [{ hello: 'world' }, { a: 42 }])
1804
+ t.assert.equal(response.headers.vary, 'accept-encoding')
1805
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
1806
+ t.assert.deepEqual(JSON.parse(payload.toString()), [{ hello: 'world' }, { a: 42 }])
1807
1807
  })
1808
1808
 
1809
- t.test('when using `onSend` hook', async (t) => {
1809
+ test('when using `onSend` hook', async (t) => {
1810
1810
  t.plan(3)
1811
1811
 
1812
1812
  const fastify = Fastify()
@@ -1831,14 +1831,14 @@ test('It should support stream1 :', async (t) => {
1831
1831
  }
1832
1832
  })
1833
1833
  const payload = zlib.gunzipSync(response.rawPayload)
1834
- t.equal(response.headers.vary, 'accept-encoding')
1835
- t.equal(response.headers['content-encoding'], 'gzip')
1836
- t.same(JSON.parse(payload.toString()), [{ hello: 'world' }, { a: 42 }])
1834
+ t.assert.equal(response.headers.vary, 'accept-encoding')
1835
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
1836
+ t.assert.deepEqual(JSON.parse(payload.toString()), [{ hello: 'world' }, { a: 42 }])
1837
1837
  })
1838
1838
  })
1839
1839
 
1840
- test('It should remove `Content-Length` header :', async (t) => {
1841
- t.test('using `reply.compress()`', async (t) => {
1840
+ describe('It should remove `Content-Length` header :', async () => {
1841
+ test('using `reply.compress()`', async (t) => {
1842
1842
  t.plan(4)
1843
1843
 
1844
1844
  const fastify = Fastify()
@@ -1866,13 +1866,13 @@ test('It should remove `Content-Length` header :', async (t) => {
1866
1866
  })
1867
1867
  const file = readFileSync('./package.json', 'utf8')
1868
1868
  const payload = zlib.inflateSync(response.rawPayload)
1869
- t.equal(response.headers.vary, 'accept-encoding')
1870
- t.equal(response.headers['content-encoding'], 'deflate')
1871
- t.notOk(response.headers['content-length'], 'no content length')
1872
- t.equal(payload.toString('utf-8'), file)
1869
+ t.assert.equal(response.headers.vary, 'accept-encoding')
1870
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
1871
+ t.assert.ok(!response.headers['content-length'], 'no content length')
1872
+ t.assert.equal(payload.toString('utf-8'), file)
1873
1873
  })
1874
1874
 
1875
- t.test('using `reply.compress()` on a Stream when `inflateIfDeflated` is `true` and `X-No-Compression` request header is `true`', async (t) => {
1875
+ test('using `reply.compress()` on a Stream when `inflateIfDeflated` is `true` and `X-No-Compression` request header is `true`', async (t) => {
1876
1876
  t.plan(4)
1877
1877
 
1878
1878
  const fastify = Fastify()
@@ -1892,13 +1892,13 @@ test('It should remove `Content-Length` header :', async (t) => {
1892
1892
  }
1893
1893
  })
1894
1894
  const file = readFileSync('./package.json', 'utf8')
1895
- t.equal(response.statusCode, 200)
1896
- t.notOk(response.headers.vary)
1897
- t.notOk(response.headers['content-length'], 'no content length')
1898
- t.equal(file, response.payload)
1895
+ t.assert.equal(response.statusCode, 200)
1896
+ t.assert.ok(!response.headers.vary)
1897
+ t.assert.ok(!response.headers['content-length'], 'no content length')
1898
+ t.assert.equal(file, response.payload)
1899
1899
  })
1900
1900
 
1901
- t.test('using `onSend` hook', async (t) => {
1901
+ test('using `onSend` hook', async (t) => {
1902
1902
  t.plan(4)
1903
1903
 
1904
1904
  const fastify = Fastify()
@@ -1926,13 +1926,13 @@ test('It should remove `Content-Length` header :', async (t) => {
1926
1926
  })
1927
1927
  const file = readFileSync('./package.json', 'utf8')
1928
1928
  const payload = zlib.inflateSync(response.rawPayload)
1929
- t.equal(response.headers.vary, 'accept-encoding')
1930
- t.equal(response.headers['content-encoding'], 'deflate')
1931
- t.notOk(response.headers['content-length'], 'no content length')
1932
- t.equal(payload.toString('utf-8'), file)
1929
+ t.assert.equal(response.headers.vary, 'accept-encoding')
1930
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
1931
+ t.assert.ok(!response.headers['content-length'], 'no content length')
1932
+ t.assert.equal(payload.toString('utf-8'), file)
1933
1933
  })
1934
1934
 
1935
- t.test('using `onSend` hook on a Stream When `inflateIfDeflated` is `true` and `X-No-Compression` request header is `true`', async (t) => {
1935
+ test('using `onSend` hook on a Stream When `inflateIfDeflated` is `true` and `X-No-Compression` request header is `true`', async (t) => {
1936
1936
  t.plan(4)
1937
1937
 
1938
1938
  const fastify = Fastify()
@@ -1952,15 +1952,15 @@ test('It should remove `Content-Length` header :', async (t) => {
1952
1952
  }
1953
1953
  })
1954
1954
  const file = readFileSync('./package.json', 'utf8')
1955
- t.equal(response.statusCode, 200)
1956
- t.notOk(response.headers.vary)
1957
- t.notOk(response.headers['content-length'], 'no content length')
1958
- t.equal(file, response.payload)
1955
+ t.assert.equal(response.statusCode, 200)
1956
+ t.assert.ok(!response.headers.vary)
1957
+ t.assert.ok(!response.headers['content-length'], 'no content length')
1958
+ t.assert.equal(file, response.payload)
1959
1959
  })
1960
1960
  })
1961
1961
 
1962
- test('When `removeContentLengthHeader` is `false`, it should not remove `Content-Length` header :', async (t) => {
1963
- t.test('using `reply.compress()`', async (t) => {
1962
+ describe('When `removeContentLengthHeader` is `false`, it should not remove `Content-Length` header :', async () => {
1963
+ test('using `reply.compress()`', async (t) => {
1964
1964
  t.plan(4)
1965
1965
 
1966
1966
  const fastify = Fastify()
@@ -1988,13 +1988,13 @@ test('When `removeContentLengthHeader` is `false`, it should not remove `Content
1988
1988
  })
1989
1989
  const file = readFileSync('./package.json', 'utf8')
1990
1990
  const payload = zlib.inflateSync(response.rawPayload)
1991
- t.equal(response.headers.vary, 'accept-encoding')
1992
- t.equal(response.headers['content-encoding'], 'deflate')
1993
- t.equal(response.headers['content-length'], payload.length.toString())
1994
- t.equal(payload.toString('utf-8'), file)
1991
+ t.assert.equal(response.headers.vary, 'accept-encoding')
1992
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
1993
+ t.assert.equal(response.headers['content-length'], payload.length.toString())
1994
+ t.assert.equal(payload.toString('utf-8'), file)
1995
1995
  })
1996
1996
 
1997
- t.test('using `onSend` hook', async (t) => {
1997
+ test('using `onSend` hook', async (t) => {
1998
1998
  t.plan(4)
1999
1999
 
2000
2000
  const fastify = Fastify()
@@ -2022,15 +2022,15 @@ test('When `removeContentLengthHeader` is `false`, it should not remove `Content
2022
2022
  })
2023
2023
  const file = readFileSync('./package.json', 'utf8')
2024
2024
  const payload = zlib.inflateSync(response.rawPayload)
2025
- t.equal(response.headers.vary, 'accept-encoding')
2026
- t.equal(response.headers['content-encoding'], 'deflate')
2027
- t.equal(response.headers['content-length'], payload.length.toString())
2028
- t.equal(payload.toString('utf-8'), file)
2025
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2026
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
2027
+ t.assert.equal(response.headers['content-length'], payload.length.toString())
2028
+ t.assert.equal(payload.toString('utf-8'), file)
2029
2029
  })
2030
2030
  })
2031
2031
 
2032
- test('It should add hooks correctly: ', async (t) => {
2033
- t.test('`onRequest` hooks', async (t) => {
2032
+ describe('It should add hooks correctly: ', async () => {
2033
+ test('`onRequest` hooks', async (t) => {
2034
2034
  t.plan(14)
2035
2035
 
2036
2036
  const fastify = Fastify()
@@ -2074,11 +2074,11 @@ test('It should add hooks correctly: ', async (t) => {
2074
2074
  }
2075
2075
  }).then((response) => {
2076
2076
  const payload = zlib.inflateSync(response.rawPayload)
2077
- t.equal(response.statusCode, 200)
2078
- t.notOk(response.headers['content-length'], 'no content length')
2079
- t.equal(response.headers['x-fastify-global-test'], 'ok')
2080
- t.equal(response.headers['x-fastify-test-one'], 'ok')
2081
- t.equal(payload.toString('utf-8'), file)
2077
+ t.assert.equal(response.statusCode, 200)
2078
+ t.assert.ok(!response.headers['content-length'], 'no content length')
2079
+ t.assert.equal(response.headers['x-fastify-global-test'], 'ok')
2080
+ t.assert.equal(response.headers['x-fastify-test-one'], 'ok')
2081
+ t.assert.equal(payload.toString('utf-8'), file)
2082
2082
  }).catch((err) => {
2083
2083
  t.error(err)
2084
2084
  })
@@ -2091,11 +2091,11 @@ test('It should add hooks correctly: ', async (t) => {
2091
2091
  }
2092
2092
  }).then((response) => {
2093
2093
  const payload = zlib.inflateSync(response.rawPayload)
2094
- t.equal(response.statusCode, 200)
2095
- t.notOk(response.headers['content-length'], 'no content length')
2096
- t.equal(response.headers['x-fastify-global-test'], 'ok')
2097
- t.equal(response.headers['x-fastify-test-two'], 'ok')
2098
- t.equal(payload.toString('utf-8'), file)
2094
+ t.assert.equal(response.statusCode, 200)
2095
+ t.assert.ok(!response.headers['content-length'], 'no content length')
2096
+ t.assert.equal(response.headers['x-fastify-global-test'], 'ok')
2097
+ t.assert.equal(response.headers['x-fastify-test-two'], 'ok')
2098
+ t.assert.equal(payload.toString('utf-8'), file)
2099
2099
  }).catch((err) => {
2100
2100
  t.error(err)
2101
2101
  })
@@ -2108,16 +2108,16 @@ test('It should add hooks correctly: ', async (t) => {
2108
2108
  }
2109
2109
  }).then((response) => {
2110
2110
  const payload = zlib.inflateSync(response.rawPayload)
2111
- t.equal(response.statusCode, 200)
2112
- t.notOk(response.headers['content-length'], 'no content length')
2113
- t.equal(response.headers['x-fastify-global-test'], 'ok')
2114
- t.equal(payload.toString('utf-8'), file)
2111
+ t.assert.equal(response.statusCode, 200)
2112
+ t.assert.ok(!response.headers['content-length'], 'no content length')
2113
+ t.assert.equal(response.headers['x-fastify-global-test'], 'ok')
2114
+ t.assert.equal(payload.toString('utf-8'), file)
2115
2115
  }).catch((err) => {
2116
2116
  t.error(err)
2117
2117
  })
2118
2118
  })
2119
2119
 
2120
- t.test('`onSend` hooks', async (t) => {
2120
+ test('`onSend` hooks', async (t) => {
2121
2121
  t.plan(14)
2122
2122
 
2123
2123
  const fastify = Fastify()
@@ -2161,11 +2161,11 @@ test('It should add hooks correctly: ', async (t) => {
2161
2161
  }
2162
2162
  }).then((response) => {
2163
2163
  const payload = zlib.inflateSync(response.rawPayload)
2164
- t.equal(response.statusCode, 200)
2165
- t.notOk(response.headers['content-length'], 'no content length')
2166
- t.equal(response.headers['x-fastify-global-test'], 'ok')
2167
- t.equal(response.headers['x-fastify-test-one'], 'ok')
2168
- t.equal(payload.toString('utf-8'), file)
2164
+ t.assert.equal(response.statusCode, 200)
2165
+ t.assert.ok(!response.headers['content-length'], 'no content length')
2166
+ t.assert.equal(response.headers['x-fastify-global-test'], 'ok')
2167
+ t.assert.equal(response.headers['x-fastify-test-one'], 'ok')
2168
+ t.assert.equal(payload.toString('utf-8'), file)
2169
2169
  }).catch((err) => {
2170
2170
  t.error(err)
2171
2171
  })
@@ -2178,11 +2178,11 @@ test('It should add hooks correctly: ', async (t) => {
2178
2178
  }
2179
2179
  }).then((response) => {
2180
2180
  const payload = zlib.inflateSync(response.rawPayload)
2181
- t.equal(response.statusCode, 200)
2182
- t.notOk(response.headers['content-length'], 'no content length')
2183
- t.equal(response.headers['x-fastify-global-test'], 'ok')
2184
- t.equal(response.headers['x-fastify-test-two'], 'ok')
2185
- t.equal(payload.toString('utf-8'), file)
2181
+ t.assert.equal(response.statusCode, 200)
2182
+ t.assert.ok(!response.headers['content-length'], 'no content length')
2183
+ t.assert.equal(response.headers['x-fastify-global-test'], 'ok')
2184
+ t.assert.equal(response.headers['x-fastify-test-two'], 'ok')
2185
+ t.assert.equal(payload.toString('utf-8'), file)
2186
2186
  }).catch((err) => {
2187
2187
  t.error(err)
2188
2188
  })
@@ -2195,16 +2195,16 @@ test('It should add hooks correctly: ', async (t) => {
2195
2195
  }
2196
2196
  }).then((response) => {
2197
2197
  const payload = zlib.inflateSync(response.rawPayload)
2198
- t.equal(response.statusCode, 200)
2199
- t.notOk(response.headers['content-length'], 'no content length')
2200
- t.equal(response.headers['x-fastify-global-test'], 'ok')
2201
- t.equal(payload.toString('utf-8'), file)
2198
+ t.assert.equal(response.statusCode, 200)
2199
+ t.assert.ok(!response.headers['content-length'], 'no content length')
2200
+ t.assert.equal(response.headers['x-fastify-global-test'], 'ok')
2201
+ t.assert.equal(payload.toString('utf-8'), file)
2202
2202
  }).catch((err) => {
2203
2203
  t.error(err)
2204
2204
  })
2205
2205
  })
2206
2206
 
2207
- t.test('`preParsing` hooks', async (t) => {
2207
+ test('`preParsing` hooks', async (t) => {
2208
2208
  t.plan(14)
2209
2209
 
2210
2210
  const fastify = Fastify()
@@ -2255,11 +2255,11 @@ test('It should add hooks correctly: ', async (t) => {
2255
2255
  }
2256
2256
  }).then((response) => {
2257
2257
  const payload = zlib.inflateSync(response.rawPayload)
2258
- t.equal(response.statusCode, 200)
2259
- t.notOk(response.headers['content-length'], 'no content length')
2260
- t.equal(response.headers['x-fastify-global-test'], 'ok')
2261
- t.equal(response.headers['x-fastify-test-one'], 'ok')
2262
- t.equal(payload.toString('utf-8'), file)
2258
+ t.assert.equal(response.statusCode, 200)
2259
+ t.assert.ok(!response.headers['content-length'], 'no content length')
2260
+ t.assert.equal(response.headers['x-fastify-global-test'], 'ok')
2261
+ t.assert.equal(response.headers['x-fastify-test-one'], 'ok')
2262
+ t.assert.equal(payload.toString('utf-8'), file)
2263
2263
  }).catch((err) => {
2264
2264
  t.error(err)
2265
2265
  })
@@ -2272,11 +2272,11 @@ test('It should add hooks correctly: ', async (t) => {
2272
2272
  }
2273
2273
  }).then((response) => {
2274
2274
  const payload = zlib.inflateSync(response.rawPayload)
2275
- t.equal(response.statusCode, 200)
2276
- t.notOk(response.headers['content-length'], 'no content length')
2277
- t.equal(response.headers['x-fastify-global-test'], 'ok')
2278
- t.equal(response.headers['x-fastify-test-two'], 'ok')
2279
- t.equal(payload.toString('utf-8'), file)
2275
+ t.assert.equal(response.statusCode, 200)
2276
+ t.assert.ok(!response.headers['content-length'], 'no content length')
2277
+ t.assert.equal(response.headers['x-fastify-global-test'], 'ok')
2278
+ t.assert.equal(response.headers['x-fastify-test-two'], 'ok')
2279
+ t.assert.equal(payload.toString('utf-8'), file)
2280
2280
  }).catch((err) => {
2281
2281
  t.error(err)
2282
2282
  })
@@ -2289,18 +2289,18 @@ test('It should add hooks correctly: ', async (t) => {
2289
2289
  }
2290
2290
  }).then((response) => {
2291
2291
  const payload = zlib.inflateSync(response.rawPayload)
2292
- t.equal(response.statusCode, 200)
2293
- t.notOk(response.headers['content-length'], 'no content length')
2294
- t.equal(response.headers['x-fastify-global-test'], 'ok')
2295
- t.equal(payload.toString('utf-8'), file)
2292
+ t.assert.equal(response.statusCode, 200)
2293
+ t.assert.ok(!response.headers['content-length'], 'no content length')
2294
+ t.assert.equal(response.headers['x-fastify-global-test'], 'ok')
2295
+ t.assert.equal(payload.toString('utf-8'), file)
2296
2296
  }).catch((err) => {
2297
2297
  t.error(err)
2298
2298
  })
2299
2299
  })
2300
2300
  })
2301
2301
 
2302
- test('When `Accept-Encoding` request header values are not supported and `onUnsupportedEncoding` is defined :', async (t) => {
2303
- t.test('it should call the defined `onUnsupportedEncoding()` method', async (t) => {
2302
+ describe('When `Accept-Encoding` request header values are not supported and `onUnsupportedEncoding` is defined :', async () => {
2303
+ test('it should call the defined `onUnsupportedEncoding()` method', async (t) => {
2304
2304
  t.plan(2)
2305
2305
 
2306
2306
  const fastify = Fastify()
@@ -2325,11 +2325,11 @@ test('When `Accept-Encoding` request header values are not supported and `onUnsu
2325
2325
  'accept-encoding': 'hello'
2326
2326
  }
2327
2327
  })
2328
- t.equal(response.statusCode, 406)
2329
- t.same(JSON.parse(response.payload), { hello: 'hello' })
2328
+ t.assert.equal(response.statusCode, 406)
2329
+ t.assert.deepEqual(JSON.parse(response.payload), { hello: 'hello' })
2330
2330
  })
2331
2331
 
2332
- t.test('it should call the defined `onUnsupportedEncoding()` method and throw an error', async (t) => {
2332
+ test('it should call the defined `onUnsupportedEncoding()` method and throw an error', async (t) => {
2333
2333
  t.plan(2)
2334
2334
 
2335
2335
  const fastify = Fastify()
@@ -2354,8 +2354,8 @@ test('When `Accept-Encoding` request header values are not supported and `onUnsu
2354
2354
  'accept-encoding': 'hello'
2355
2355
  }
2356
2356
  })
2357
- t.equal(response.statusCode, 406)
2358
- t.same(JSON.parse(response.payload), {
2357
+ t.assert.equal(response.statusCode, 406)
2358
+ t.assert.deepEqual(JSON.parse(response.payload), {
2359
2359
  error: 'Not Acceptable',
2360
2360
  message: 'testing error',
2361
2361
  statusCode: 406
@@ -2363,8 +2363,8 @@ test('When `Accept-Encoding` request header values are not supported and `onUnsu
2363
2363
  })
2364
2364
  })
2365
2365
 
2366
- test('`Accept-Encoding` request header values :', async (t) => {
2367
- t.test('can contain white space', async (t) => {
2366
+ describe('`Accept-Encoding` request header values :', async () => {
2367
+ test('can contain white space', async (t) => {
2368
2368
  t.plan(3)
2369
2369
 
2370
2370
  const fastify = Fastify()
@@ -2384,12 +2384,12 @@ test('`Accept-Encoding` request header values :', async (t) => {
2384
2384
  }
2385
2385
  })
2386
2386
  const payload = zlib.gunzipSync(response.rawPayload)
2387
- t.equal(response.headers.vary, 'accept-encoding')
2388
- t.equal(response.headers['content-encoding'], 'gzip')
2389
- t.equal(payload.toString('utf-8'), JSON.stringify(json))
2387
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2388
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
2389
+ t.assert.equal(payload.toString('utf-8'), JSON.stringify(json))
2390
2390
  })
2391
2391
 
2392
- t.test('can contain mixed uppercase and lowercase characters (e.g.: compressing a Stream)', async (t) => {
2392
+ test('can contain mixed uppercase and lowercase characters (e.g.: compressing a Stream)', async (t) => {
2393
2393
  t.plan(3)
2394
2394
 
2395
2395
  const fastify = Fastify()
@@ -2410,12 +2410,12 @@ test('`Accept-Encoding` request header values :', async (t) => {
2410
2410
  })
2411
2411
  const file = readFileSync('./package.json', 'utf8')
2412
2412
  const payload = zlib.gunzipSync(response.rawPayload)
2413
- t.equal(response.headers.vary, 'accept-encoding')
2414
- t.equal(response.headers['content-encoding'], 'gzip')
2415
- t.equal(payload.toString('utf-8'), file)
2413
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2414
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
2415
+ t.assert.equal(payload.toString('utf-8'), file)
2416
2416
  })
2417
2417
 
2418
- t.test('can contain mixed uppercase and lowercase characters (e.g.: compressing a Buffer)', async (t) => {
2418
+ test('can contain mixed uppercase and lowercase characters (e.g.: compressing a Buffer)', async (t) => {
2419
2419
  t.plan(1)
2420
2420
 
2421
2421
  const fastify = Fastify()
@@ -2434,10 +2434,10 @@ test('`Accept-Encoding` request header values :', async (t) => {
2434
2434
  }
2435
2435
  })
2436
2436
  const payload = zlib.gunzipSync(response.rawPayload)
2437
- t.equal(payload.toString('utf-8'), buf.toString())
2437
+ t.assert.equal(payload.toString('utf-8'), buf.toString())
2438
2438
  })
2439
2439
 
2440
- t.test('should support `gzip` alias value `x-gzip`', async (t) => {
2440
+ test('should support `gzip` alias value `x-gzip`', async (t) => {
2441
2441
  t.plan(3)
2442
2442
 
2443
2443
  const fastify = Fastify()
@@ -2460,12 +2460,12 @@ test('`Accept-Encoding` request header values :', async (t) => {
2460
2460
  })
2461
2461
  const file = readFileSync('./package.json', 'utf8')
2462
2462
  const payload = zlib.gunzipSync(response.rawPayload)
2463
- t.equal(response.headers.vary, 'accept-encoding')
2464
- t.equal(response.headers['content-encoding'], 'gzip')
2465
- t.equal(payload.toString('utf-8'), file)
2463
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2464
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
2465
+ t.assert.equal(payload.toString('utf-8'), file)
2466
2466
  })
2467
2467
 
2468
- t.test('should support quality syntax', async (t) => {
2468
+ test('should support quality syntax', async (t) => {
2469
2469
  t.plan(3)
2470
2470
 
2471
2471
  const fastify = Fastify()
@@ -2488,9 +2488,9 @@ test('`Accept-Encoding` request header values :', async (t) => {
2488
2488
  })
2489
2489
  const file = readFileSync('./package.json', 'utf8')
2490
2490
  const payload = zlib.inflateSync(response.rawPayload)
2491
- t.equal(response.headers.vary, 'accept-encoding')
2492
- t.equal(response.headers['content-encoding'], 'deflate')
2493
- t.equal(payload.toString('utf-8'), file)
2491
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2492
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
2493
+ t.assert.equal(payload.toString('utf-8'), file)
2494
2494
  })
2495
2495
  })
2496
2496
 
@@ -2514,9 +2514,9 @@ test('It should compress data if `customTypes` is set and matches `Content-Type`
2514
2514
  })
2515
2515
  const file = readFileSync('./package.json', 'utf8')
2516
2516
  const payload = zlib.gunzipSync(response.rawPayload)
2517
- t.equal(response.headers.vary, 'accept-encoding')
2518
- t.equal(response.headers['content-encoding'], 'gzip')
2519
- t.equal(payload.toString('utf-8'), file)
2517
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2518
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
2519
+ t.assert.equal(payload.toString('utf-8'), file)
2520
2520
  })
2521
2521
 
2522
2522
  test('It should compress data if `customTypes` is a function and returns true on the provided `Content-Type` reply header value', async (t) => {
@@ -2539,9 +2539,9 @@ test('It should compress data if `customTypes` is a function and returns true on
2539
2539
  })
2540
2540
  const file = readFileSync('./package.json', 'utf8')
2541
2541
  const payload = zlib.gunzipSync(response.rawPayload)
2542
- t.equal(response.headers.vary, 'accept-encoding')
2543
- t.equal(response.headers['content-encoding'], 'gzip')
2544
- t.equal(payload.toString('utf-8'), file)
2542
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2543
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
2544
+ t.assert.equal(payload.toString('utf-8'), file)
2545
2545
  })
2546
2546
 
2547
2547
  test('It should not apply `customTypes` option if the passed value is not a RegExp or Function', async (t) => {
@@ -2563,9 +2563,9 @@ test('It should not apply `customTypes` option if the passed value is not a RegE
2563
2563
  'accept-encoding': 'gzip'
2564
2564
  }
2565
2565
  })
2566
- t.notOk(response.headers.vary)
2567
- t.notOk(response.headers['content-encoding'])
2568
- t.equal(response.statusCode, 200)
2566
+ t.assert.ok(!response.headers.vary)
2567
+ t.assert.ok(!response.headers['content-encoding'])
2568
+ t.assert.equal(response.statusCode, 200)
2569
2569
  })
2570
2570
 
2571
2571
  test('When `encodings` option is set, it should only use the registered value', async (t) => {
@@ -2585,13 +2585,13 @@ test('When `encodings` option is set, it should only use the registered value',
2585
2585
  'accept-encoding': 'br,gzip,deflate'
2586
2586
  }
2587
2587
  })
2588
- t.equal(response.headers.vary, 'accept-encoding')
2589
- t.equal(response.headers['content-encoding'], 'deflate')
2590
- t.equal(response.statusCode, 200)
2588
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2589
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
2590
+ t.assert.equal(response.statusCode, 200)
2591
2591
  })
2592
2592
 
2593
- test('It should send data compressed according to `brotliOptions` :', async (t) => {
2594
- t.test('when using br encoding', async (t) => {
2593
+ describe('It should send data compressed according to `brotliOptions` :', async () => {
2594
+ test('when using br encoding', async (t) => {
2595
2595
  t.plan(4)
2596
2596
  const brotliOptions = {
2597
2597
  params: {
@@ -2619,15 +2619,15 @@ test('It should send data compressed according to `brotliOptions` :', async (t)
2619
2619
 
2620
2620
  const file = readFileSync('./package.json', 'utf8')
2621
2621
  const payload = zlib.brotliDecompressSync(response.rawPayload, brotliOptions)
2622
- t.equal(response.headers.vary, 'accept-encoding')
2623
- t.equal(response.headers['content-encoding'], 'br')
2624
- t.equal(payload.toString('utf-8'), file)
2622
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2623
+ t.assert.equal(response.headers['content-encoding'], 'br')
2624
+ t.assert.equal(payload.toString('utf-8'), file)
2625
2625
 
2626
2626
  const compressedPayload = zlib.brotliCompressSync(file, brotliOptions)
2627
- t.same(response.rawPayload, compressedPayload)
2627
+ t.assert.deepEqual(response.rawPayload, compressedPayload)
2628
2628
  })
2629
2629
 
2630
- t.test('default BROTLI_PARAM_QUALITY to be 4', async (t) => {
2630
+ test('default BROTLI_PARAM_QUALITY to be 4', async (t) => {
2631
2631
  t.plan(1)
2632
2632
 
2633
2633
  const fastify = Fastify()
@@ -2652,12 +2652,12 @@ test('It should send data compressed according to `brotliOptions` :', async (t)
2652
2652
  params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 4 }
2653
2653
  }
2654
2654
  const compressedPayload = zlib.brotliCompressSync(file, defaultBrotliOptions)
2655
- t.same(response.rawPayload, compressedPayload)
2655
+ t.assert.deepEqual(response.rawPayload, compressedPayload)
2656
2656
  })
2657
2657
  })
2658
2658
 
2659
- test('It should send data compressed according to `zlibOptions` :', async (t) => {
2660
- t.test('when using deflate encoding', async (t) => {
2659
+ describe('It should send data compressed according to `zlibOptions` :', async () => {
2660
+ test('when using deflate encoding', async (t) => {
2661
2661
  t.plan(3)
2662
2662
 
2663
2663
  const zlibOptions = {
@@ -2685,12 +2685,12 @@ test('It should send data compressed according to `zlibOptions` :', async (t) =>
2685
2685
  }
2686
2686
  })
2687
2687
  const file = readFileSync('./package.json')
2688
- t.equal(response.headers.vary, 'accept-encoding')
2689
- t.equal(response.headers['content-encoding'], 'deflate')
2690
- t.same(response.rawPayload, zlib.deflateSync(file, zlibOptions))
2688
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2689
+ t.assert.equal(response.headers['content-encoding'], 'deflate')
2690
+ t.assert.deepEqual(response.rawPayload, zlib.deflateSync(file, zlibOptions))
2691
2691
  })
2692
2692
 
2693
- t.test('when using gzip encoding', async (t) => {
2693
+ test('when using gzip encoding', async (t) => {
2694
2694
  t.plan(3)
2695
2695
 
2696
2696
  const zlibOptions = { level: 1 }
@@ -2715,9 +2715,9 @@ test('It should send data compressed according to `zlibOptions` :', async (t) =>
2715
2715
  }
2716
2716
  })
2717
2717
  const file = readFileSync('./package.json')
2718
- t.equal(response.headers.vary, 'accept-encoding')
2719
- t.equal(response.headers['content-encoding'], 'gzip')
2720
- t.same(response.rawPayload, zlib.gzipSync(file, zlibOptions))
2718
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2719
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
2720
+ t.assert.deepEqual(response.rawPayload, zlib.gzipSync(file, zlibOptions))
2721
2721
  })
2722
2722
  })
2723
2723
 
@@ -2748,7 +2748,7 @@ test('It should concat `accept-encoding` to `Vary` reply header if present', asy
2748
2748
  'accept-encoding': 'deflate'
2749
2749
  }
2750
2750
  }).then((response) => {
2751
- t.same(response.headers.vary, 'different-header, accept-encoding')
2751
+ t.assert.deepEqual(response.headers.vary, 'different-header, accept-encoding')
2752
2752
  }).catch((err) => {
2753
2753
  t.error(err)
2754
2754
  })
@@ -2760,7 +2760,7 @@ test('It should concat `accept-encoding` to `Vary` reply header if present', asy
2760
2760
  'accept-encoding': 'deflate'
2761
2761
  }
2762
2762
  }).then((response) => {
2763
- t.same(response.headers.vary, 'different-header, my-header, accept-encoding')
2763
+ t.assert.deepEqual(response.headers.vary, 'different-header, my-header, accept-encoding')
2764
2764
  }).catch((err) => {
2765
2765
  t.error(err)
2766
2766
  })
@@ -2793,7 +2793,7 @@ test('It should not add `accept-encoding` to `Vary` reply header if already pres
2793
2793
  'accept-encoding': 'deflate'
2794
2794
  }
2795
2795
  }).then((response) => {
2796
- t.same(response.headers.vary, 'accept-encoding,different-header')
2796
+ t.assert.deepEqual(response.headers.vary, 'accept-encoding,different-header')
2797
2797
  }).catch((err) => {
2798
2798
  t.error(err)
2799
2799
  })
@@ -2805,7 +2805,7 @@ test('It should not add `accept-encoding` to `Vary` reply header if already pres
2805
2805
  'accept-encoding': 'deflate'
2806
2806
  }
2807
2807
  }).then((response) => {
2808
- t.same(response.headers.vary, 'accept-encoding, different-header, my-header')
2808
+ t.assert.deepEqual(response.headers.vary, 'accept-encoding, different-header, my-header')
2809
2809
  }).catch((err) => {
2810
2810
  t.error(err)
2811
2811
  })
@@ -2832,9 +2832,9 @@ test('It should follow the `Accept-Encoding` request header encoding order', asy
2832
2832
  })
2833
2833
  const file = readFileSync('./package.json', 'utf8')
2834
2834
  const payload = zlib.brotliDecompressSync(response.rawPayload)
2835
- t.equal(response.headers.vary, 'accept-encoding')
2836
- t.equal(response.headers['content-encoding'], 'br')
2837
- t.equal(payload.toString('utf-8'), file)
2835
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2836
+ t.assert.equal(response.headers['content-encoding'], 'br')
2837
+ t.assert.equal(payload.toString('utf-8'), file)
2838
2838
  })
2839
2839
 
2840
2840
  test('It should sort and follow custom `encodings` options', async (t) => {
@@ -2861,9 +2861,9 @@ test('It should sort and follow custom `encodings` options', async (t) => {
2861
2861
  })
2862
2862
  const file = readFileSync('./package.json', 'utf8')
2863
2863
  const payload = zlib.brotliDecompressSync(response.rawPayload)
2864
- t.equal(response.headers.vary, 'accept-encoding')
2865
- t.equal(response.headers['content-encoding'], 'br')
2866
- t.equal(payload.toString('utf-8'), file)
2864
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2865
+ t.assert.equal(response.headers['content-encoding'], 'br')
2866
+ t.assert.equal(payload.toString('utf-8'), file)
2867
2867
  })
2868
2868
 
2869
2869
  test('It should sort and prefer the order of custom `encodings` options', async (t) => {
@@ -2891,9 +2891,9 @@ test('It should sort and prefer the order of custom `encodings` options', async
2891
2891
 
2892
2892
  const file = readFileSync('./package.json', 'utf8')
2893
2893
  const payload = zlib.gunzipSync(response.rawPayload)
2894
- t.equal(response.headers.vary, 'accept-encoding')
2895
- t.equal(response.headers['content-encoding'], 'gzip')
2896
- t.equal(payload.toString('utf-8'), file)
2894
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2895
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
2896
+ t.assert.equal(payload.toString('utf-8'), file)
2897
2897
  })
2898
2898
 
2899
2899
  test('It should sort and follow custom `requestEncodings` options', async (t) => {
@@ -2920,13 +2920,13 @@ test('It should sort and follow custom `requestEncodings` options', async (t) =>
2920
2920
  })
2921
2921
  const file = readFileSync('./package.json', 'utf8')
2922
2922
  const payload = zlib.brotliDecompressSync(response.rawPayload)
2923
- t.equal(response.headers.vary, 'accept-encoding')
2924
- t.equal(response.headers['content-encoding'], 'br')
2925
- t.equal(payload.toString('utf-8'), file)
2923
+ t.assert.equal(response.headers.vary, 'accept-encoding')
2924
+ t.assert.equal(response.headers['content-encoding'], 'br')
2925
+ t.assert.equal(payload.toString('utf-8'), file)
2926
2926
  })
2927
2927
 
2928
- test('It should uncompress data when `Accept-Encoding` request header is missing :', async (t) => {
2929
- t.test('using the fallback Node.js `zlib.createInflate()` method', async (t) => {
2928
+ describe('It should uncompress data when `Accept-Encoding` request header is missing :', async () => {
2929
+ test('using the fallback Node.js `zlib.createInflate()` method', async (t) => {
2930
2930
  t.plan(4)
2931
2931
 
2932
2932
  const fastify = Fastify()
@@ -2946,13 +2946,13 @@ test('It should uncompress data when `Accept-Encoding` request header is missing
2946
2946
  url: '/',
2947
2947
  method: 'GET'
2948
2948
  })
2949
- t.equal(response.statusCode, 200)
2950
- t.notOk(response.headers.vary)
2951
- t.notOk(response.headers['content-encoding'])
2952
- t.same(JSON.parse('' + response.payload), json)
2949
+ t.assert.equal(response.statusCode, 200)
2950
+ t.assert.ok(!response.headers.vary)
2951
+ t.assert.ok(!response.headers['content-encoding'])
2952
+ t.assert.deepEqual(JSON.parse('' + response.payload), json)
2953
2953
  })
2954
2954
 
2955
- t.test('using the fallback Node.js `zlib.createGunzip()` method', async (t) => {
2955
+ test('using the fallback Node.js `zlib.createGunzip()` method', async (t) => {
2956
2956
  t.plan(4)
2957
2957
 
2958
2958
  const fastify = Fastify()
@@ -2972,13 +2972,13 @@ test('It should uncompress data when `Accept-Encoding` request header is missing
2972
2972
  url: '/',
2973
2973
  method: 'GET'
2974
2974
  })
2975
- t.equal(response.statusCode, 200)
2976
- t.notOk(response.headers.vary)
2977
- t.notOk(response.headers['content-encoding'])
2978
- t.same(JSON.parse('' + response.payload), json)
2975
+ t.assert.equal(response.statusCode, 200)
2976
+ t.assert.ok(!response.headers.vary)
2977
+ t.assert.ok(!response.headers['content-encoding'])
2978
+ t.assert.deepEqual(JSON.parse('' + response.payload), json)
2979
2979
  })
2980
2980
 
2981
- t.test('when the data is a deflated Buffer', async (t) => {
2981
+ test('when the data is a deflated Buffer', async (t) => {
2982
2982
  t.plan(4)
2983
2983
 
2984
2984
  const fastify = Fastify()
@@ -2997,13 +2997,13 @@ test('It should uncompress data when `Accept-Encoding` request header is missing
2997
2997
  url: '/',
2998
2998
  method: 'GET'
2999
2999
  })
3000
- t.equal(response.statusCode, 200)
3001
- t.notOk(response.headers.vary)
3002
- t.notOk(response.headers['content-encoding'])
3003
- t.same(JSON.parse('' + response.payload), json)
3000
+ t.assert.equal(response.statusCode, 200)
3001
+ t.assert.ok(!response.headers.vary)
3002
+ t.assert.ok(!response.headers['content-encoding'])
3003
+ t.assert.deepEqual(JSON.parse('' + response.payload), json)
3004
3004
  })
3005
3005
 
3006
- t.test('when the data is a gzipped Buffer', async (t) => {
3006
+ test('when the data is a gzipped Buffer', async (t) => {
3007
3007
  t.plan(4)
3008
3008
 
3009
3009
  const fastify = Fastify()
@@ -3022,13 +3022,13 @@ test('It should uncompress data when `Accept-Encoding` request header is missing
3022
3022
  url: '/',
3023
3023
  method: 'GET'
3024
3024
  })
3025
- t.equal(response.statusCode, 200)
3026
- t.notOk(response.headers.vary)
3027
- t.notOk(response.headers['content-encoding'])
3028
- t.same(JSON.parse('' + response.payload), json)
3025
+ t.assert.equal(response.statusCode, 200)
3026
+ t.assert.ok(!response.headers.vary)
3027
+ t.assert.ok(!response.headers['content-encoding'])
3028
+ t.assert.deepEqual(JSON.parse('' + response.payload), json)
3029
3029
  })
3030
3030
 
3031
- t.test('when the data is a deflated Stream', async (t) => {
3031
+ test('when the data is a deflated Stream', async (t) => {
3032
3032
  t.plan(4)
3033
3033
 
3034
3034
  const fastify = Fastify()
@@ -3050,13 +3050,13 @@ test('It should uncompress data when `Accept-Encoding` request header is missing
3050
3050
  method: 'GET'
3051
3051
  })
3052
3052
  const file = readFileSync('./package.json', 'utf8')
3053
- t.equal(response.statusCode, 200)
3054
- t.notOk(response.headers.vary)
3055
- t.notOk(response.headers['content-encoding'])
3056
- t.equal(response.rawPayload.toString('utf-8'), file)
3053
+ t.assert.equal(response.statusCode, 200)
3054
+ t.assert.ok(!response.headers.vary)
3055
+ t.assert.ok(!response.headers['content-encoding'])
3056
+ t.assert.equal(response.rawPayload.toString('utf-8'), file)
3057
3057
  })
3058
3058
 
3059
- t.test('when the data is a gzipped Stream', async (t) => {
3059
+ test('when the data is a gzipped Stream', async (t) => {
3060
3060
  t.plan(4)
3061
3061
 
3062
3062
  const fastify = Fastify()
@@ -3078,13 +3078,13 @@ test('It should uncompress data when `Accept-Encoding` request header is missing
3078
3078
  method: 'GET'
3079
3079
  })
3080
3080
  const file = readFileSync('./package.json', 'utf8')
3081
- t.equal(response.statusCode, 200)
3082
- t.notOk(response.headers.vary)
3083
- t.notOk(response.headers['content-encoding'])
3084
- t.equal(response.rawPayload.toString('utf-8'), file)
3081
+ t.assert.equal(response.statusCode, 200)
3082
+ t.assert.ok(!response.headers.vary)
3083
+ t.assert.ok(!response.headers['content-encoding'])
3084
+ t.assert.equal(response.rawPayload.toString('utf-8'), file)
3085
3085
  })
3086
3086
 
3087
- t.test('when the data has been compressed multiple times', async (t) => {
3087
+ test('when the data has been compressed multiple times', async (t) => {
3088
3088
  t.plan(4)
3089
3089
 
3090
3090
  const fastify = Fastify()
@@ -3107,15 +3107,15 @@ test('It should uncompress data when `Accept-Encoding` request header is missing
3107
3107
  url: '/',
3108
3108
  method: 'GET'
3109
3109
  })
3110
- t.equal(response.statusCode, 200)
3111
- t.notOk(response.headers.vary)
3112
- t.notOk(response.headers['content-encoding'])
3113
- t.same(JSON.parse('' + response.payload), json)
3110
+ t.assert.equal(response.statusCode, 200)
3111
+ t.assert.ok(!response.headers.vary)
3112
+ t.assert.ok(!response.headers['content-encoding'])
3113
+ t.assert.deepEqual(JSON.parse('' + response.payload), json)
3114
3114
  })
3115
3115
  })
3116
3116
 
3117
- test('When `onUnsupportedEncoding` is set and the `Accept-Encoding` request header value is an unsupported encoding', async (t) => {
3118
- t.test('it should call the defined `onUnsupportedEncoding()` method', async (t) => {
3117
+ describe('When `onUnsupportedEncoding` is set and the `Accept-Encoding` request header value is an unsupported encoding', async () => {
3118
+ test('it should call the defined `onUnsupportedEncoding()` method', async (t) => {
3119
3119
  t.plan(3)
3120
3120
 
3121
3121
  const fastify = Fastify()
@@ -3140,12 +3140,12 @@ test('When `onUnsupportedEncoding` is set and the `Accept-Encoding` request head
3140
3140
  'accept-encoding': 'hello'
3141
3141
  }
3142
3142
  })
3143
- t.equal(response.statusCode, 406)
3144
- t.notOk(response.headers.vary)
3145
- t.same(JSON.parse(response.payload), { hello: 'hello' })
3143
+ t.assert.equal(response.statusCode, 406)
3144
+ t.assert.ok(!response.headers.vary)
3145
+ t.assert.deepEqual(JSON.parse(response.payload), { hello: 'hello' })
3146
3146
  })
3147
3147
 
3148
- t.test('it should call the defined `onUnsupportedEncoding()` method and throw an error', async (t) => {
3148
+ test('it should call the defined `onUnsupportedEncoding()` method and throw an error', async (t) => {
3149
3149
  t.plan(2)
3150
3150
 
3151
3151
  const fastify = Fastify()
@@ -3170,8 +3170,8 @@ test('When `onUnsupportedEncoding` is set and the `Accept-Encoding` request head
3170
3170
  'accept-encoding': 'hello'
3171
3171
  }
3172
3172
  })
3173
- t.equal(response.statusCode, 406)
3174
- t.same(JSON.parse(response.payload), {
3173
+ t.assert.equal(response.statusCode, 406)
3174
+ t.assert.deepEqual(JSON.parse(response.payload), {
3175
3175
  error: 'Not Acceptable',
3176
3176
  message: 'testing error',
3177
3177
  statusCode: 406
@@ -3179,19 +3179,19 @@ test('When `onUnsupportedEncoding` is set and the `Accept-Encoding` request head
3179
3179
  })
3180
3180
  })
3181
3181
 
3182
- test('It should error :', async (t) => {
3183
- t.test('when `encodings` array is empty', (t) => {
3182
+ describe('It should error :', async () => {
3183
+ test('when `encodings` array is empty', async (t) => {
3184
3184
  t.plan(1)
3185
3185
 
3186
3186
  const fastify = Fastify()
3187
3187
  fastify.register(compressPlugin, { encodings: [] })
3188
-
3189
- fastify.ready(err => {
3190
- t.ok(err instanceof Error)
3188
+ await t.assert.rejects(async () => fastify.ready(), {
3189
+ name: 'Error',
3190
+ message: 'The `encodings` option array must have at least 1 item.'
3191
3191
  })
3192
3192
  })
3193
3193
 
3194
- t.test('when no entries in `encodings` are supported', (t) => {
3194
+ test('when no entries in `encodings` are supported', (t) => {
3195
3195
  t.plan(1)
3196
3196
 
3197
3197
  const fastify = Fastify()
@@ -3199,8 +3199,9 @@ test('It should error :', async (t) => {
3199
3199
  encodings: ['(not-a-real-encoding)']
3200
3200
  })
3201
3201
 
3202
- fastify.ready(err => {
3203
- t.ok(err instanceof Error)
3202
+ t.assert.rejects(async () => fastify.ready(), {
3203
+ name: 'Error',
3204
+ message: 'None of the passed `encodings` were supported — compression not possible.'
3204
3205
  })
3205
3206
  })
3206
3207
  })
@@ -3220,8 +3221,8 @@ test('It should return an error when using `reply.compress()` with a missing pay
3220
3221
  method: 'GET'
3221
3222
  })
3222
3223
  const payload = JSON.parse(response.payload)
3223
- t.equal(response.statusCode, 500)
3224
- t.same({
3224
+ t.assert.equal(response.statusCode, 500)
3225
+ t.assert.deepEqual({
3225
3226
  error: 'Internal Server Error',
3226
3227
  message: 'Internal server error',
3227
3228
  statusCode: 500
@@ -3261,9 +3262,9 @@ for (const contentType of defaultSupportedContentTypes) {
3261
3262
  })
3262
3263
  const file = readFileSync('./package.json', 'utf8')
3263
3264
  const payload = zlib.gunzipSync(response.rawPayload)
3264
- t.equal(response.headers.vary, 'accept-encoding')
3265
- t.equal(response.headers['content-encoding'], 'gzip')
3266
- t.equal(payload.toString('utf-8'), file)
3265
+ t.assert.equal(response.headers.vary, 'accept-encoding')
3266
+ t.assert.equal(response.headers['content-encoding'], 'gzip')
3267
+ t.assert.equal(payload.toString('utf-8'), file)
3267
3268
  })
3268
3269
  }
3269
3270
 
@@ -3292,8 +3293,8 @@ for (const contentType of notByDefaultSupportedContentTypes) {
3292
3293
  }
3293
3294
  })
3294
3295
  const file = readFileSync('./package.json', 'utf8')
3295
- t.notOk(response.headers.vary)
3296
- t.notOk(response.headers['content-encoding'])
3297
- t.equal(response.rawPayload.toString('utf-8'), file)
3296
+ t.assert.ok(!response.headers.vary)
3297
+ t.assert.ok(!response.headers['content-encoding'])
3298
+ t.assert.equal(response.rawPayload.toString('utf-8'), file)
3298
3299
  })
3299
3300
  }