@@ -5,26 +5,10 @@ var crypto = require('crypto')
55var http = require ( 'http' )
66var request = require ( 'supertest' )
77var 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' )
189
1910var compression = require ( '..' )
2011
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-
2812describe ( 'compression()' , function ( ) {
2913 it ( 'should skip HEAD' , function ( done ) {
3014 var server = createServer ( { threshold : 0 } , function ( req , res ) {
@@ -321,7 +305,7 @@ describe('compression()', function () {
321305 . expect ( 200 , done )
322306 } )
323307
324- describeHttp2 ( 'http2' , function ( ) {
308+ describe ( 'http2' , function ( ) {
325309 it ( 'should work with http2 server' , function ( done ) {
326310 var server = createHttp2Server ( { threshold : 0 } , function ( req , res ) {
327311 res . setHeader ( http2 . constants . HTTP2_HEADER_CONTENT_TYPE , 'text/plain' )
@@ -517,7 +501,7 @@ describe('compression()', function () {
517501 } )
518502
519503 describe ( 'when "Accept-Encoding: br"' , function ( ) {
520- brotli ( 'should respond with br' , function ( done ) {
504+ it ( 'should respond with br' , function ( done ) {
521505 var server = createServer ( { threshold : 0 } , function ( req , res ) {
522506 res . setHeader ( 'Content-Type' , 'text/plain' )
523507 res . end ( 'hello, world' )
@@ -531,7 +515,7 @@ describe('compression()', function () {
531515 } )
532516
533517 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 ) {
535519 var params = { }
536520 params [ zlib . constants . BROTLI_PARAM_QUALITY ] = 11
537521
@@ -546,7 +530,7 @@ describe('compression()', function () {
546530 . expect ( 'Content-Encoding' , 'br' , done )
547531 } )
548532
549- brotli ( 'shouldn\'t break compression when gzip is requested' , function ( done ) {
533+ it ( 'shouldn\'t break compression when gzip is requested' , function ( done ) {
550534 var params = { }
551535 params [ zlib . constants . BROTLI_PARAM_QUALITY ] = 8
552536
@@ -591,8 +575,7 @@ describe('compression()', function () {
591575 } )
592576
593577 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 ) {
596579 var server = createServer ( { threshold : 0 } , function ( req , res ) {
597580 res . setHeader ( 'Content-Type' , 'text/plain' )
598581 res . end ( 'hello, world' )
@@ -604,9 +587,7 @@ describe('compression()', function () {
604587 . expect ( 'Content-Encoding' , 'br' , done )
605588 } )
606589
607- brotli = hasBrotliSupport ? it . skip : it
608-
609- brotli ( 'should respond with gzip' , function ( done ) {
590+ it . skip ( 'should respond with gzip' , function ( done ) {
610591 var server = createServer ( { threshold : 0 } , function ( req , res ) {
611592 res . setHeader ( 'Content-Type' , 'text/plain' )
612593 res . end ( 'hello, world' )
@@ -620,7 +601,7 @@ describe('compression()', function () {
620601 } )
621602
622603 describe ( 'when "Accept-Encoding: deflate, gzip, br"' , function ( ) {
623- brotli ( 'should respond with br' , function ( done ) {
604+ it ( 'should respond with br' , function ( done ) {
624605 var server = createServer ( { threshold : 0 } , function ( req , res ) {
625606 res . setHeader ( 'Content-Type' , 'text/plain' )
626607 res . end ( 'hello, world' )
@@ -634,7 +615,7 @@ describe('compression()', function () {
634615 } )
635616
636617 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 ) {
638619 var server = createServer ( { threshold : 0 } , function ( req , res ) {
639620 res . setHeader ( 'Content-Type' , 'text/plain' )
640621 res . end ( 'hello, world' )
@@ -648,7 +629,7 @@ describe('compression()', function () {
648629 } )
649630
650631 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 ) {
652633 var server = createServer ( { threshold : 0 } , function ( req , res ) {
653634 res . setHeader ( 'Content-Type' , 'text/plain' )
654635 res . end ( 'hello, world' )
@@ -662,7 +643,7 @@ describe('compression()', function () {
662643 } )
663644
664645 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 ) {
666647 var server = createServer ( { threshold : 0 } , function ( req , res ) {
667648 res . setHeader ( 'Content-Type' , 'text/plain' )
668649 res . end ( 'hello, world' )
@@ -676,7 +657,7 @@ describe('compression()', function () {
676657 } )
677658
678659 describe ( 'when "Accept-Encoding: deflate, br"' , function ( ) {
679- brotli ( 'should respond with br' , function ( done ) {
660+ it ( 'should respond with br' , function ( done ) {
680661 var server = createServer ( { threshold : 0 } , function ( req , res ) {
681662 res . setHeader ( 'Content-Type' , 'text/plain' )
682663 res . end ( 'hello, world' )
@@ -827,7 +808,7 @@ describe('compression()', function () {
827808 . end ( )
828809 } )
829810
830- brotli ( 'should flush small chunks for brotli' , function ( done ) {
811+ it ( 'should flush small chunks for brotli' , function ( done ) {
831812 var chunks = 0
832813 var next
833814 var server = createServer ( { threshold : 0 } , function ( req , res ) {
@@ -933,7 +914,7 @@ describe('compression()', function () {
933914 . expect ( 200 , 'hello, world' , done )
934915 } )
935916
936- brotli ( 'should compress when enforceEncoding is brotli' , function ( done ) {
917+ it ( 'should compress when enforceEncoding is brotli' , function ( done ) {
937918 var server = createServer ( { threshold : 0 , enforceEncoding : 'br' } , function ( req , res ) {
938919 res . setHeader ( 'Content-Type' , 'text/plain' )
939920 res . end ( 'hello, world' )
0 commit comments