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

* use const instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10479 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Italo A. Casas <me@italoacasas.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
39 lines
974 B
JavaScript
39 lines
974 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const path = require('path');
|
|
const fs = require('fs');
|
|
|
|
const emptyFile = path.join(common.fixturesDir, 'empty.txt');
|
|
|
|
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
|
|
assert.ifError(error);
|
|
|
|
const read = fs.createReadStream(emptyFile, { 'fd': fd });
|
|
|
|
read.once('data', () => {
|
|
throw new Error('data event should not emit');
|
|
});
|
|
|
|
read.once('end', common.mustCall(function endEvent1() {}));
|
|
}));
|
|
|
|
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
|
|
assert.ifError(error);
|
|
|
|
const read = fs.createReadStream(emptyFile, { 'fd': fd });
|
|
read.pause();
|
|
|
|
read.once('data', () => {
|
|
throw new Error('data event should not emit');
|
|
});
|
|
|
|
read.once('end', function endEvent2() {
|
|
throw new Error('end event should not emit');
|
|
});
|
|
|
|
setTimeout(common.mustCall(() => {
|
|
assert.strictEqual(read.isPaused(), true);
|
|
}), common.platformTimeout(50));
|
|
}));
|