2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-30 18:38:06 -05:00
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const path = require('path');
|
|
|
|
const fs = require('fs');
|
2011-03-02 00:35:32 +09:00
|
|
|
|
2015-06-09 11:40:55 -07:00
|
|
|
common.refreshTmpDir();
|
|
|
|
|
2016-07-12 19:47:32 -04:00
|
|
|
{
|
|
|
|
const file = path.join(common.tmpDir, 'write-end-test0.txt');
|
|
|
|
const stream = fs.createWriteStream(file);
|
2013-02-11 14:01:18 +01:00
|
|
|
stream.end();
|
|
|
|
stream.on('close', common.mustCall(function() { }));
|
2016-07-12 19:47:32 -04:00
|
|
|
}
|
2011-03-02 00:35:32 +09:00
|
|
|
|
2016-07-12 19:47:32 -04:00
|
|
|
{
|
|
|
|
const file = path.join(common.tmpDir, 'write-end-test1.txt');
|
|
|
|
const stream = fs.createWriteStream(file);
|
2012-10-05 08:26:49 -07:00
|
|
|
stream.end('a\n', 'utf8');
|
2013-02-11 14:01:18 +01:00
|
|
|
stream.on('close', common.mustCall(function() {
|
2016-07-12 19:47:32 -04:00
|
|
|
const content = fs.readFileSync(file, 'utf8');
|
|
|
|
assert.strictEqual(content, 'a\n');
|
2013-02-11 14:01:18 +01:00
|
|
|
}));
|
2016-07-12 19:47:32 -04:00
|
|
|
}
|