@@ -670,6 +670,57 @@ describe('node-fetch', () => {
670670 } )
671671 } )
672672
673+ it ( 'should decompress zstandard response' , function ( ) {
674+ if ( typeof zlib . createZstdDecompress !== 'function' ) {
675+ this . skip ( )
676+ }
677+
678+ const url = `${ base } zstandard`
679+ return fetch ( url ) . then ( res => {
680+ assert . strictEqual ( res . headers . get ( 'content-type' ) , 'text/plain' )
681+ assert . strictEqual ( res . headers . get ( 'content-encoding' ) , 'zstd' )
682+ return res . text ( ) . then ( result => {
683+ assert . strictEqual ( typeof result , 'string' )
684+ assert . strictEqual ( result , 'hello world' )
685+ } )
686+ } )
687+ } )
688+
689+ it ( 'should handle not modified response with zstandard encoding' , function ( ) {
690+ if ( typeof zlib . createZstdDecompress !== 'function' ) {
691+ this . skip ( )
692+ }
693+ const url = `${ base } not-modified/zstandard`
694+ return fetch ( url ) . then ( res => {
695+ assert . strictEqual ( res . status , 304 )
696+ assert . strictEqual ( res . statusText , 'Not Modified' )
697+ assert . strictEqual ( res . headers . get ( 'content-encoding' ) , 'zstd' )
698+ assert . strictEqual ( res . ok , false )
699+ return res . text ( ) . then ( result => {
700+ assert . strictEqual ( typeof result , 'string' )
701+ assert . strictEqual ( result , '' )
702+ } )
703+ } )
704+ } )
705+
706+ it ( 'should handle no content response with zstandard encoding' , function ( ) {
707+ if ( typeof zlib . createZstdDecompress !== 'function' ) {
708+ this . skip ( )
709+ }
710+
711+ const url = `${ base } no-content/zstandard`
712+ return fetch ( url ) . then ( res => {
713+ assert . strictEqual ( res . status , 204 )
714+ assert . strictEqual ( res . statusText , 'No Content' )
715+ assert . strictEqual ( res . headers . get ( 'content-encoding' ) , 'zstd' )
716+ assert . strictEqual ( res . ok , true )
717+ return res . text ( ) . then ( result => {
718+ assert . strictEqual ( typeof result , 'string' )
719+ assert . strictEqual ( result , '' )
720+ } )
721+ } )
722+ } )
723+
673724 it ( 'should handle no content response with brotli encoding' , function ( ) {
674725 if ( typeof zlib . createBrotliDecompress !== 'function' ) {
675726 this . skip ( )
0 commit comments