From 76bb3cbff92ad3285e4b4696146ca22030bc1789 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 19 Dec 2016 21:40:40 -0800 Subject: [PATCH] test: refactor test-stream2-writable * add duration to setTimeout() * assert.equal() -> assert.strictEqual() * remove unused function arguments * normalize indentation PR-URL: https://github.com/nodejs/node/pull/10353 Reviewed-By: Julian Duque Reviewed-By: Matteo Collina --- test/parallel/test-stream2-writable.js | 62 +++++++++++++------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/test/parallel/test-stream2-writable.js b/test/parallel/test-stream2-writable.js index 81e57d06eb3bec..65d914dca0a78a 100644 --- a/test/parallel/test-stream2-writable.js +++ b/test/parallel/test-stream2-writable.js @@ -45,8 +45,8 @@ function run() { var fn = next[1]; console.log('# %s', name); fn({ - same: assert.deepEqual, - equal: assert.equal, + same: assert.deepStrictEqual, + equal: assert.strictEqual, end: function() { count--; run(); @@ -56,7 +56,7 @@ function run() { // ensure all tests have run process.on('exit', function() { - assert.equal(count, 0); + assert.strictEqual(count, 0); }); process.nextTick(run); @@ -136,17 +136,17 @@ test('write bufferize', function(t) { }); var encodings = - [ 'hex', - 'utf8', - 'utf-8', - 'ascii', - 'binary', - 'base64', - 'ucs2', - 'ucs-2', - 'utf16le', - 'utf-16le', - undefined ]; + [ 'hex', + 'utf8', + 'utf-8', + 'ascii', + 'binary', + 'base64', + 'ucs2', + 'ucs-2', + 'utf16le', + 'utf-16le', + undefined ]; tw.on('finish', function() { t.same(tw.buffer, chunks, 'got the expected chunks'); @@ -173,17 +173,17 @@ test('write no bufferize', function(t) { }; var encodings = - [ 'hex', - 'utf8', - 'utf-8', - 'ascii', - 'binary', - 'base64', - 'ucs2', - 'ucs-2', - 'utf16le', - 'utf-16le', - undefined ]; + [ 'hex', + 'utf8', + 'utf-8', + 'ascii', + 'binary', + 'base64', + 'ucs2', + 'ucs-2', + 'utf16le', + 'utf-16le', + undefined ]; tw.on('finish', function() { t.same(tw.buffer, chunks, 'got the expected chunks'); @@ -199,7 +199,7 @@ test('write no bufferize', function(t) { test('write callbacks', function(t) { var callbacks = chunks.map(function(chunk, i) { - return [i, function(er) { + return [i, function() { callbacks._called[i] = chunk; }]; }).reduce(function(set, x) { @@ -270,7 +270,7 @@ test('end callback called after write callback', function(t) { test('encoding should be ignored for buffers', function(t) { var tw = new W(); var hex = '018b5e9a8f6236ffe30e31baf80d2cf6eb'; - tw._write = function(chunk, encoding, cb) { + tw._write = function(chunk) { t.equal(chunk.toString('hex'), hex); t.end(); }; @@ -282,7 +282,7 @@ test('writables are not pipable', function(t) { var w = new W(); w._write = function() {}; var gotError = false; - w.on('error', function(er) { + w.on('error', function() { gotError = true; }); w.pipe(process.stdout); @@ -295,7 +295,7 @@ test('duplexes are pipable', function(t) { d._read = function() {}; d._write = function() {}; var gotError = false; - d.on('error', function(er) { + d.on('error', function() { gotError = true; }); d.pipe(process.stdout); @@ -329,7 +329,7 @@ test('dont end while writing', function(t) { setTimeout(function() { this.writing = false; cb(); - }); + }, 1); }; w.on('finish', function() { assert(wrote); @@ -366,7 +366,7 @@ test('finish does not come before sync _write cb', function(t) { assert(writeCb); t.end(); }); - w.write(Buffer(0), function(er) { + w.write(Buffer.alloc(0), function() { writeCb = true; }); w.end();