Skip to content

Commit

Permalink
test: refactor test-stream2-unpipe-drain
Browse files Browse the repository at this point in the history
- Change var to const
- Remove dependency crypto

PR-URL: #10033
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
storytimesolutions authored and MylesBorins committed Feb 1, 2017
1 parent 7020e9f commit a9cd1d1
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions test/parallel/test-stream2-unpipe-drain.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var stream = require('stream');
require('../common');
const assert = require('assert');

if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
var crypto = require('crypto');

var util = require('util');
const stream = require('stream');
const util = require('util');

function TestWriter() {
stream.Writable.call(this);
Expand All @@ -21,7 +15,7 @@ TestWriter.prototype._write = function(buffer, encoding, callback) {
// super slow write stream (callback never called)
};

var dest = new TestWriter();
const dest = new TestWriter();

function TestReader(id) {
stream.Readable.call(this);
Expand All @@ -31,11 +25,11 @@ util.inherits(TestReader, stream.Readable);

TestReader.prototype._read = function(size) {
this.reads += 1;
this.push(crypto.randomBytes(size));
this.push(Buffer.alloc(size));
};

var src1 = new TestReader();
var src2 = new TestReader();
const src1 = new TestReader();
const src2 = new TestReader();

src1.pipe(dest);

Expand All @@ -55,6 +49,6 @@ src1.once('readable', function() {


process.on('exit', function() {
assert.equal(src1.reads, 2);
assert.equal(src2.reads, 2);
assert.strictEqual(src1.reads, 2);
assert.strictEqual(src2.reads, 2);
});

0 comments on commit a9cd1d1

Please sign in to comment.