11
22describe ( "Shim test" , function ( ) {
3+ var haveCompressionStream = typeof CompressionStream !== "undefined" && typeof Response !== "undefined"
34
4- this
5- . test ( "setTimeout additional parameters" , function ( assert ) {
5+ test ( "setTimeout additional parameters" , function ( assert ) {
66 assert . plan ( 2 )
77 var interval = setInterval ( function ( a ) {
88 assert . equal ( a , 2 )
@@ -12,7 +12,7 @@ describe("Shim test", function() {
1212 assert . equal ( a , 3 )
1313 } , 1 , 3 )
1414 } )
15- . test ( "shim.js" , function ( assert , mock ) {
15+ test ( "shim.js" , function ( assert , mock ) {
1616
1717 if ( describe . env === "browser" ) {
1818 var lib = window
@@ -312,7 +312,8 @@ describe("Shim test", function() {
312312 assert . end ( )
313313
314314 } )
315- . test ( "JSON" , function ( assert ) {
315+
316+ test ( "JSON" , function ( assert ) {
316317 var undef
317318 , lib = describe . env === "browser" ? window : require ( "../shim.js" )
318319 , str1 = '{"a":1,"cb":"2\\n3\\\\","d":[-1,0,1,2,{"g\\b":true},false,"",null,null,null,1],"e":{"f":null}}'
@@ -329,6 +330,19 @@ describe("Shim test", function() {
329330 assert . equal ( JSON . parse ( '"a\u2029b\\u2029c"' ) , "a\u2029b\u2029c" )
330331 assert . end ( )
331332 } )
333+
334+ test ( "CompressionStream" , haveCompressionStream && async function ( assert ) {
335+ var res = await Array . from (
336+ new Uint8Array (
337+ await new Response (
338+ new Blob ( [ new TextEncoder ( ) . encode ( "hello world" ) ] )
339+ . stream ( )
340+ . pipeThrough ( new CompressionStream ( "deflate" ) )
341+ ) . arrayBuffer ( )
342+ )
343+ ) . map ( b => b . toString ( 16 ) . padStart ( 2 , '0' ) ) . join ( '' )
344+ assert . equal ( res , "789ccb48cdc9c95728cf2fca4901001a0b045d" )
345+ } )
332346} )
333347
334348describe ( "DOM tests" , typeof window === "undefined" ? "No window" : function ( ) {
0 commit comments