From 08f5db112f9e35160bd8b639782ec33f003fb1bd Mon Sep 17 00:00:00 2001 From: isaacs Date: Thu, 7 Mar 2013 14:28:32 -0800 Subject: [PATCH] test: Make stream2-transform less timing-dependent --- test/simple/test-stream2-transform.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/test/simple/test-stream2-transform.js b/test/simple/test-stream2-transform.js index 3f629a23a4..500c48b8ac 100644 --- a/test/simple/test-stream2-transform.js +++ b/test/simple/test-stream2-transform.js @@ -141,13 +141,13 @@ test('async passthrough', function(t) { pt.write(new Buffer('kuel')); pt.end(); - setTimeout(function() { + pt.on('finish', function() { t.equal(pt.read(5).toString(), 'foogb'); t.equal(pt.read(5).toString(), 'arkba'); t.equal(pt.read(5).toString(), 'zykue'); t.equal(pt.read(5).toString(), 'l'); t.end(); - }, 100); + }); }); test('assymetric transform (expand)', function(t) { @@ -170,7 +170,7 @@ test('assymetric transform (expand)', function(t) { pt.write(new Buffer('kuel')); pt.end(); - setTimeout(function() { + pt.on('finish', function() { t.equal(pt.read(5).toString(), 'foogf'); t.equal(pt.read(5).toString(), 'oogba'); t.equal(pt.read(5).toString(), 'rkbar'); @@ -179,7 +179,7 @@ test('assymetric transform (expand)', function(t) { t.equal(pt.read(5).toString(), 'uelku'); t.equal(pt.read(5).toString(), 'el'); t.end(); - }, 200); + }); }); test('assymetric transform (compress)', function(t) { @@ -205,11 +205,9 @@ test('assymetric transform (compress)', function(t) { pt._flush = function(cb) { // just output whatever we have. - setTimeout(function() { - pt.push(new Buffer(this.state)); - this.state = ''; - cb(); - }.bind(this), 10); + pt.push(new Buffer(this.state)); + this.state = ''; + cb(); }; pt.write(new Buffer('aaaa')); @@ -229,12 +227,12 @@ test('assymetric transform (compress)', function(t) { pt.end(); // 'abcdeabcdeabcd' - setTimeout(function() { + pt.on('finish', function() { t.equal(pt.read(5).toString(), 'abcde'); t.equal(pt.read(5).toString(), 'abcde'); t.equal(pt.read(5).toString(), 'abcd'); t.end(); - }, 200); + }); });