0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-fs-write-stream-end.js
cjihrig 4a408321d9 test: cleanup IIFE tests
A number of test files use IIFEs to separate distinct tests from
each other in the same file. The project has been moving toward
using block scopes and let/const in favor of IIFEs. This commit
moves IIFE tests to block scopes. Some additional cleanup such
as use of strictEqual() and common.mustCall() is also included.

PR-URL: https://github.com/nodejs/node/pull/7694
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
2016-07-14 22:07:14 -04:00

25 lines
634 B
JavaScript

'use strict';
var common = require('../common');
var assert = require('assert');
var path = require('path');
var fs = require('fs');
common.refreshTmpDir();
{
const file = path.join(common.tmpDir, 'write-end-test0.txt');
const stream = fs.createWriteStream(file);
stream.end();
stream.on('close', common.mustCall(function() { }));
}
{
const file = path.join(common.tmpDir, 'write-end-test1.txt');
const stream = fs.createWriteStream(file);
stream.end('a\n', 'utf8');
stream.on('close', common.mustCall(function() {
const content = fs.readFileSync(file, 'utf8');
assert.strictEqual(content, 'a\n');
}));
}