Skip to content

Commit a9cd1d1

Browse files
storytimesolutionsMylesBorins
authored andcommittedFeb 1, 2017
test: refactor test-stream2-unpipe-drain
- Change var to const - Remove dependency crypto PR-URL: #10033 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 7020e9f commit a9cd1d1

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed
 

‎test/parallel/test-stream2-unpipe-drain.js

+10-16
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var stream = require('stream');
2+
require('../common');
3+
const assert = require('assert');
54

6-
if (!common.hasCrypto) {
7-
common.skip('missing crypto');
8-
return;
9-
}
10-
var crypto = require('crypto');
11-
12-
var util = require('util');
5+
const stream = require('stream');
6+
const util = require('util');
137

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

24-
var dest = new TestWriter();
18+
const dest = new TestWriter();
2519

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

3226
TestReader.prototype._read = function(size) {
3327
this.reads += 1;
34-
this.push(crypto.randomBytes(size));
28+
this.push(Buffer.alloc(size));
3529
};
3630

37-
var src1 = new TestReader();
38-
var src2 = new TestReader();
31+
const src1 = new TestReader();
32+
const src2 = new TestReader();
3933

4034
src1.pipe(dest);
4135

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

5650

5751
process.on('exit', function() {
58-
assert.equal(src1.reads, 2);
59-
assert.equal(src2.reads, 2);
52+
assert.strictEqual(src1.reads, 2);
53+
assert.strictEqual(src2.reads, 2);
6054
});

0 commit comments

Comments
 (0)
Please sign in to comment.