Skip to content

Commit

Permalink
test: refactor test-stream2-writable
Browse files Browse the repository at this point in the history
* add duration to setTimeout()
* assert.equal() -> assert.strictEqual()
* remove unused function arguments
* normalize indentation

PR-URL: #10353
Reviewed-By: Julian Duque <julianduquej@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
Trott authored and MylesBorins committed Jan 24, 2017
1 parent 0fae3d2 commit 80aeca7
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions test/parallel/test-stream2-writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function run() {
console.log('# %s', name);
fn({
same: assert.deepStrictEqual,
equal: assert.equal,
equal: assert.strictEqual,
end: function() {
count--;
run();
Expand All @@ -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);
Expand Down Expand Up @@ -136,18 +136,18 @@ test('write bufferize', function(t) {
});

var encodings =
[ 'hex',
'utf8',
'utf-8',
'ascii',
'latin1',
'binary',
'base64',
'ucs2',
'ucs-2',
'utf16le',
'utf-16le',
undefined ];
[ 'hex',
'utf8',
'utf-8',
'ascii',
'latin1',
'binary',
'base64',
'ucs2',
'ucs-2',
'utf16le',
'utf-16le',
undefined ];

tw.on('finish', function() {
t.same(tw.buffer, chunks, 'got the expected chunks');
Expand All @@ -174,18 +174,18 @@ test('write no bufferize', function(t) {
};

var encodings =
[ 'hex',
'utf8',
'utf-8',
'ascii',
'latin1',
'binary',
'base64',
'ucs2',
'ucs-2',
'utf16le',
'utf-16le',
undefined ];
[ 'hex',
'utf8',
'utf-8',
'ascii',
'latin1',
'binary',
'base64',
'ucs2',
'ucs-2',
'utf16le',
'utf-16le',
undefined ];

tw.on('finish', function() {
t.same(tw.buffer, chunks, 'got the expected chunks');
Expand All @@ -201,7 +201,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) {
Expand Down Expand Up @@ -272,7 +272,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();
};
Expand All @@ -284,7 +284,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);
Expand All @@ -297,7 +297,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);
Expand Down Expand Up @@ -331,7 +331,7 @@ test('dont end while writing', function(t) {
setTimeout(function() {
this.writing = false;
cb();
});
}, 1);
};
w.on('finish', function() {
assert(wrote);
Expand Down Expand Up @@ -368,7 +368,7 @@ test('finish does not come before sync _write cb', function(t) {
assert(writeCb);
t.end();
});
w.write(Buffer.alloc(0), function(er) {
w.write(Buffer.alloc(0), function() {
writeCb = true;
});
w.end();
Expand Down

0 comments on commit 80aeca7

Please sign in to comment.