test: improve test-child-process-exec-buffer

* use const instead of var for required modules
* use assert.strictEqual instead of assert.equal
* use assert.strictEqual instead of assert.ok

PR-URL: https://github.com/nodejs/node/pull/10275
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
This commit is contained in:
Adrian Estrada 2016-12-16 19:31:46 -05:00 коммит произвёл Italo A. Casas
Родитель 4a257568e2
Коммит f7f662cad5
1 изменённых файлов: 12 добавлений и 10 удалений

Просмотреть файл

@ -1,22 +1,24 @@
'use strict';
const common = require('../common');
var assert = require('assert');
var exec = require('child_process').exec;
var os = require('os');
var str = 'hello';
const assert = require('assert');
const exec = require('child_process').exec;
const os = require('os');
const str = 'hello';
// default encoding
exec('echo ' + str, common.mustCall(function(err, stdout, stderr) {
assert.ok('string', typeof stdout, 'Expected stdout to be a string');
assert.ok('string', typeof stderr, 'Expected stderr to be a string');
assert.equal(str + os.EOL, stdout);
assert.strictEqual(typeof stdout, 'string', 'Expected stdout to be a string');
assert.strictEqual(typeof stderr, 'string', 'Expected stderr to be a string');
assert.strictEqual(str + os.EOL, stdout);
}));
// no encoding (Buffers expected)
exec('echo ' + str, {
encoding: null
}, common.mustCall(function(err, stdout, stderr) {
assert.ok(stdout instanceof Buffer, 'Expected stdout to be a Buffer');
assert.ok(stderr instanceof Buffer, 'Expected stderr to be a Buffer');
assert.equal(str + os.EOL, stdout.toString());
assert.strictEqual(stdout instanceof Buffer, true,
'Expected stdout to be a Buffer');
assert.strictEqual(stderr instanceof Buffer, true,
'Expected stderr to be a Buffer');
assert.strictEqual(str + os.EOL, stdout.toString());
}));