react / wstein / node_modules / browserify / node_modules / browserify-zlib / test / test-zlib-convenience-methods.js
80529 views// Copyright Joyent, Inc. and other Node contributors.1//2// Permission is hereby granted, free of charge, to any person obtaining a3// copy of this software and associated documentation files (the4// "Software"), to deal in the Software without restriction, including5// without limitation the rights to use, copy, modify, merge, publish,6// distribute, sublicense, and/or sell copies of the Software, and to permit7// persons to whom the Software is furnished to do so, subject to the8// following conditions:9//10// The above copyright notice and this permission notice shall be included11// in all copies or substantial portions of the Software.12//13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS14// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF15// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN16// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,17// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR18// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE19// USE OR OTHER DEALINGS IN THE SOFTWARE.2021// test convenience methods with and without options supplied2223var tape = require('tape');24var zlib = require('../');2526var expect = 'blahblahblahblahblahblah';27var opts = {28level: 9,29chunkSize: 1024,30};3132[33['gzip', 'gunzip'],34['gzip', 'unzip'],35['deflate', 'inflate'],36['deflateRaw', 'inflateRaw'],37].forEach(function(method) {38tape(method.join(' '), function(t) {39t.plan(4);4041zlib[method[0]](expect, opts, function(err, result) {42zlib[method[1]](result, opts, function(err, result) {43t.deepEqual(result, new Buffer(expect),44'Should get original string after ' +45method[0] + '/' + method[1] + ' with options.');46});47});4849zlib[method[0]](expect, function(err, result) {50zlib[method[1]](result, function(err, result) {51t.deepEqual(result, new Buffer(expect),52'Should get original string after ' +53method[0] + '/' + method[1] + ' without options.');54});55});5657var result = zlib[method[0] + 'Sync'](expect, opts);58result = zlib[method[1] + 'Sync'](result, opts);59t.deepEqual(result, new Buffer(expect),60'Should get original string after ' +61method[0] + '/' + method[1] + ' with options.');6263result = zlib[method[0] + 'Sync'](expect);64result = zlib[method[1] + 'Sync'](result);65t.deepEqual(result, new Buffer(expect),66'Should get original string after ' +67method[0] + '/' + method[1] + ' without options.');68});69});707172