react / wstein / node_modules / browserify / node_modules / browserify-zlib / test / test-zlib-write-after-flush.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.2021var tape = require('tape');22var zlib = require('../');23var fs = require('fs');2425tape('write after flush', function(t) {26t.plan(2);2728var gzip = zlib.createGzip();29var gunz = zlib.createUnzip();3031gzip.pipe(gunz);3233var output = '';34var input = 'A line of data\n';35gunz.setEncoding('utf8');36gunz.on('data', function(c) {37output += c;38});3940gunz.on('end', function() {41t.equal(output, input);4243// Make sure that the flush flag was set back to normal44t.equal(gzip._flushFlag, zlib.Z_NO_FLUSH);45});4647// make sure that flush/write doesn't trigger an assert failure48gzip.flush(); write();49function write() {50gzip.write(input);51gzip.end();52gunz.read(0);53}54});555657