mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 08:42:45 +00:00

Refactor test to remove unnecessary booleans and one unnecesary timer. Instead, throw Error objects where appropriate and rely on common.mustCall(). The timer seemed to be the source of an issue when parallelizing tests. Ref: https://github.com/nodejs/node/pull/4476#issuecomment-168080875 PR-URL: https://github.com/nodejs/node/pull/4490 Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
39 lines
928 B
JavaScript
39 lines
928 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var path = require('path');
|
|
var fs = require('fs');
|
|
|
|
var emptyFile = path.join(common.fixturesDir, 'empty.txt');
|
|
|
|
fs.open(emptyFile, 'r', function(error, fd) {
|
|
assert.ifError(error);
|
|
|
|
var read = fs.createReadStream(emptyFile, { 'fd': fd });
|
|
|
|
read.once('data', function() {
|
|
throw new Error('data event should not emit');
|
|
});
|
|
|
|
read.once('end', common.mustCall(function endEvent1() {}));
|
|
});
|
|
|
|
fs.open(emptyFile, 'r', function(error, fd) {
|
|
assert.ifError(error);
|
|
|
|
var read = fs.createReadStream(emptyFile, { 'fd': fd });
|
|
read.pause();
|
|
|
|
read.once('data', function() {
|
|
throw new Error('data event should not emit');
|
|
});
|
|
|
|
read.once('end', function endEvent2() {
|
|
throw new Error('end event should not emit');
|
|
});
|
|
|
|
setTimeout(function() {
|
|
assert.equal(read.isPaused(), true);
|
|
}, common.platformTimeout(50));
|
|
});
|