@@ -5,26 +5,10 @@ var crypto = require('crypto')
5
5
var http = require ( 'http' )
6
6
var request = require ( 'supertest' )
7
7
var zlib = require ( 'zlib' )
8
-
9
- var describeHttp2 = describe . skip
10
- try {
11
- var http2 = require ( 'http2' )
12
- describeHttp2 = describe
13
- } catch ( err ) {
14
- if ( err ) {
15
- console . log ( 'http2 tests disabled.' )
16
- }
17
- }
8
+ var http2 = require ( 'http2' )
18
9
19
10
var compression = require ( '..' )
20
11
21
- /**
22
- * @const
23
- * whether current node version has brotli support
24
- */
25
- var hasBrotliSupport = 'createBrotliCompress' in zlib
26
- var brotli = hasBrotliSupport ? it : it . skip
27
-
28
12
describe ( 'compression()' , function ( ) {
29
13
it ( 'should skip HEAD' , function ( done ) {
30
14
var server = createServer ( { threshold : 0 } , function ( req , res ) {
@@ -321,7 +305,7 @@ describe('compression()', function () {
321
305
. expect ( 200 , done )
322
306
} )
323
307
324
- describeHttp2 ( 'http2' , function ( ) {
308
+ describe ( 'http2' , function ( ) {
325
309
it ( 'should work with http2 server' , function ( done ) {
326
310
var server = createHttp2Server ( { threshold : 0 } , function ( req , res ) {
327
311
res . setHeader ( http2 . constants . HTTP2_HEADER_CONTENT_TYPE , 'text/plain' )
@@ -517,7 +501,7 @@ describe('compression()', function () {
517
501
} )
518
502
519
503
describe ( 'when "Accept-Encoding: br"' , function ( ) {
520
- brotli ( 'should respond with br' , function ( done ) {
504
+ it ( 'should respond with br' , function ( done ) {
521
505
var server = createServer ( { threshold : 0 } , function ( req , res ) {
522
506
res . setHeader ( 'Content-Type' , 'text/plain' )
523
507
res . end ( 'hello, world' )
@@ -531,7 +515,7 @@ describe('compression()', function () {
531
515
} )
532
516
533
517
describe ( 'when "Accept-Encoding: br" and passing compression level' , function ( ) {
534
- brotli ( 'should respond with br' , function ( done ) {
518
+ it ( 'should respond with br' , function ( done ) {
535
519
var params = { }
536
520
params [ zlib . constants . BROTLI_PARAM_QUALITY ] = 11
537
521
@@ -546,7 +530,7 @@ describe('compression()', function () {
546
530
. expect ( 'Content-Encoding' , 'br' , done )
547
531
} )
548
532
549
- brotli ( 'shouldn\'t break compression when gzip is requested' , function ( done ) {
533
+ it ( 'shouldn\'t break compression when gzip is requested' , function ( done ) {
550
534
var params = { }
551
535
params [ zlib . constants . BROTLI_PARAM_QUALITY ] = 8
552
536
@@ -591,8 +575,7 @@ describe('compression()', function () {
591
575
} )
592
576
593
577
describe ( 'when "Accept-Encoding: gzip, br"' , function ( ) {
594
- var brotli = hasBrotliSupport ? it : it . skip
595
- brotli ( 'should respond with br' , function ( done ) {
578
+ it ( 'should respond with br' , function ( done ) {
596
579
var server = createServer ( { threshold : 0 } , function ( req , res ) {
597
580
res . setHeader ( 'Content-Type' , 'text/plain' )
598
581
res . end ( 'hello, world' )
@@ -604,9 +587,7 @@ describe('compression()', function () {
604
587
. expect ( 'Content-Encoding' , 'br' , done )
605
588
} )
606
589
607
- brotli = hasBrotliSupport ? it . skip : it
608
-
609
- brotli ( 'should respond with gzip' , function ( done ) {
590
+ it . skip ( 'should respond with gzip' , function ( done ) {
610
591
var server = createServer ( { threshold : 0 } , function ( req , res ) {
611
592
res . setHeader ( 'Content-Type' , 'text/plain' )
612
593
res . end ( 'hello, world' )
@@ -620,7 +601,7 @@ describe('compression()', function () {
620
601
} )
621
602
622
603
describe ( 'when "Accept-Encoding: deflate, gzip, br"' , function ( ) {
623
- brotli ( 'should respond with br' , function ( done ) {
604
+ it ( 'should respond with br' , function ( done ) {
624
605
var server = createServer ( { threshold : 0 } , function ( req , res ) {
625
606
res . setHeader ( 'Content-Type' , 'text/plain' )
626
607
res . end ( 'hello, world' )
@@ -634,7 +615,7 @@ describe('compression()', function () {
634
615
} )
635
616
636
617
describe ( 'when "Accept-Encoding: gzip;q=1, br;q=0.3"' , function ( ) {
637
- brotli ( 'should respond with gzip' , function ( done ) {
618
+ it ( 'should respond with gzip' , function ( done ) {
638
619
var server = createServer ( { threshold : 0 } , function ( req , res ) {
639
620
res . setHeader ( 'Content-Type' , 'text/plain' )
640
621
res . end ( 'hello, world' )
@@ -648,7 +629,7 @@ describe('compression()', function () {
648
629
} )
649
630
650
631
describe ( 'when "Accept-Encoding: gzip, br;q=0.8"' , function ( ) {
651
- brotli ( 'should respond with gzip' , function ( done ) {
632
+ it ( 'should respond with gzip' , function ( done ) {
652
633
var server = createServer ( { threshold : 0 } , function ( req , res ) {
653
634
res . setHeader ( 'Content-Type' , 'text/plain' )
654
635
res . end ( 'hello, world' )
@@ -662,7 +643,7 @@ describe('compression()', function () {
662
643
} )
663
644
664
645
describe ( 'when "Accept-Encoding: gzip;q=0.001"' , function ( ) {
665
- brotli ( 'should respond with gzip' , function ( done ) {
646
+ it ( 'should respond with gzip' , function ( done ) {
666
647
var server = createServer ( { threshold : 0 } , function ( req , res ) {
667
648
res . setHeader ( 'Content-Type' , 'text/plain' )
668
649
res . end ( 'hello, world' )
@@ -676,7 +657,7 @@ describe('compression()', function () {
676
657
} )
677
658
678
659
describe ( 'when "Accept-Encoding: deflate, br"' , function ( ) {
679
- brotli ( 'should respond with br' , function ( done ) {
660
+ it ( 'should respond with br' , function ( done ) {
680
661
var server = createServer ( { threshold : 0 } , function ( req , res ) {
681
662
res . setHeader ( 'Content-Type' , 'text/plain' )
682
663
res . end ( 'hello, world' )
@@ -827,7 +808,7 @@ describe('compression()', function () {
827
808
. end ( )
828
809
} )
829
810
830
- brotli ( 'should flush small chunks for brotli' , function ( done ) {
811
+ it ( 'should flush small chunks for brotli' , function ( done ) {
831
812
var chunks = 0
832
813
var next
833
814
var server = createServer ( { threshold : 0 } , function ( req , res ) {
@@ -933,7 +914,7 @@ describe('compression()', function () {
933
914
. expect ( 200 , 'hello, world' , done )
934
915
} )
935
916
936
- brotli ( 'should compress when enforceEncoding is brotli' , function ( done ) {
917
+ it ( 'should compress when enforceEncoding is brotli' , function ( done ) {
937
918
var server = createServer ( { threshold : 0 , enforceEncoding : 'br' } , function ( req , res ) {
938
919
res . setHeader ( 'Content-Type' , 'text/plain' )
939
920
res . end ( 'hello, world' )
0 commit comments