Skip to content

Commit 7e5710a

Browse files
committed
test: fix style nits in test-child-process-spawn-typeerror.js
Fixing multiple style nits in the test pulled over from v0.12.
1 parent 56bb942 commit 7e5710a

File tree

1 file changed

+21
-33
lines changed

1 file changed

+21
-33
lines changed

test/parallel/test-child-process-spawn-typeerror.js

+21-33
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
'use strict';
2-
var assert = require('assert'),
3-
child_process = require('child_process'),
4-
spawn = child_process.spawn,
5-
fork = child_process.fork,
6-
execFile = child_process.execFile,
7-
windows = (process.platform === 'win32'),
8-
cmd = (windows) ? 'rundll32' : 'ls',
9-
invalidcmd = 'hopefully_you_dont_have_this_on_your_machine',
10-
invalidArgsMsg = /Incorrect value of args option/,
11-
invalidOptionsMsg = /options argument must be an object/,
12-
empty = require('../common').fixturesDir + '/empty.js',
13-
errors = 0;
14-
15-
try {
16-
// Ensure this throws a TypeError
17-
var child = spawn(invalidcmd, 'this is not an array');
18-
19-
child.on('error', function(err) {
20-
errors++;
21-
});
2+
const assert = require('assert');
3+
const child_process = require('child_process');
4+
const spawn = child_process.spawn;
5+
const fork = child_process.fork;
6+
const execFile = child_process.execFile;
7+
const common = require('../common');
8+
const cmd = common.isWindows ? 'rundll32' : 'ls';
9+
const invalidcmd = 'hopefully_you_dont_have_this_on_your_machine';
10+
const invalidArgsMsg = /Incorrect value of args option/;
11+
const invalidOptionsMsg = /options argument must be an object/;
12+
const empty = common.fixturesDir + '/empty.js';
2213

23-
} catch (e) {
24-
assert.equal(e instanceof TypeError, true);
25-
}
14+
assert.throws(function() {
15+
var child = spawn(invalidcmd, 'this is not an array');
16+
child.on('error', assert.fail);
17+
}, TypeError);
2618

2719
// verify that valid argument combinations do not throw
2820
assert.doesNotThrow(function() {
@@ -62,17 +54,13 @@ assert.throws(function() {
6254
spawn(cmd, [], 1);
6355
}, invalidOptionsMsg);
6456

65-
process.on('exit', function() {
66-
assert.equal(errors, 0);
67-
});
68-
6957
// Argument types for combinatorics
70-
var a = [],
71-
o = {},
72-
c = (function callback() {}),
73-
s = 'string',
74-
u = undefined,
75-
n = null;
58+
const a = [];
59+
const o = {};
60+
const c = function callback() {};
61+
const s = 'string';
62+
const u = undefined;
63+
const n = null;
7664

7765
// function spawn(file=f [,args=a] [, options=o]) has valid combinations:
7866
// (f)

0 commit comments

Comments
 (0)