mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
cb85073709
Fixes: https://github.com/nodejs/node/issues/51993 PR-URL: https://github.com/nodejs/node/pull/52005 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
29 lines
618 B
JavaScript
29 lines
618 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const tmpdir = require('../common/tmpdir');
|
|
const { strictEqual } = require('assert');
|
|
const fs = require('fs');
|
|
|
|
// Regression test for https://github.com/nodejs/node/issues/51993
|
|
|
|
tmpdir.refresh();
|
|
|
|
const file = tmpdir.resolve('test-fs-writestream-open-write.txt');
|
|
|
|
const w = fs.createWriteStream(file);
|
|
|
|
w.on('open', common.mustCall(() => {
|
|
w.write('hello');
|
|
|
|
process.nextTick(() => {
|
|
w.write('world');
|
|
w.end();
|
|
});
|
|
}));
|
|
|
|
w.on('close', common.mustCall(() => {
|
|
strictEqual(fs.readFileSync(file, 'utf8'), 'helloworld');
|
|
fs.unlinkSync(file);
|
|
}));
|