1'use strict'; 2const common = require('../common'); 3const path = require('path'); 4const fs = require('fs'); 5 6const tmpdir = require('../common/tmpdir'); 7tmpdir.refresh(); 8 9{ 10 const file = path.join(tmpdir.path, 'write-end-test0.txt'); 11 const stream = fs.createWriteStream(file, { 12 fs: { 13 open: common.mustCall(fs.open), 14 write: common.mustCallAtLeast(fs.write, 1), 15 close: common.mustCall(fs.close), 16 } 17 }); 18 stream.end('asd'); 19 stream.on('close', common.mustCall()); 20} 21 22 23{ 24 const file = path.join(tmpdir.path, 'write-end-test1.txt'); 25 const stream = fs.createWriteStream(file, { 26 fs: { 27 open: common.mustCall(fs.open), 28 write: fs.write, 29 writev: common.mustCallAtLeast(fs.writev, 1), 30 close: common.mustCall(fs.close), 31 } 32 }); 33 stream.write('asd'); 34 stream.write('asd'); 35 stream.write('asd'); 36 stream.end(); 37 stream.on('close', common.mustCall()); 38} 39