Skip to content

Commit

Permalink
test: modify test messages to template literals
Browse files Browse the repository at this point in the history
PR-URL: nodejs#15931
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
atsui-tc authored and BridgeAR committed Oct 8, 2017
1 parent 3f5f847 commit f96745a
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions test/parallel/test-cli-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const notFoundRE = /^Error: Cannot find module/m;
const cmd = [node, ..._args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
assert.ifError(err);
assert.strictEqual(stdout, '', 'stdout produced');
assert.strictEqual(stderr, '', 'stderr produced');
assert.strictEqual(stdout, '');
assert.strictEqual(stderr, '');
}));
});
});
Expand All @@ -54,16 +54,16 @@ const notFoundRE = /^Error: Cannot find module/m;
const cmd = [node, ..._args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
assert.strictEqual(err instanceof Error, true);
assert.strictEqual(err.code, 1, `code === ${err.code}`);
assert.strictEqual(err.code, 1);

// no stdout should be produced
assert.strictEqual(stdout, '', 'stdout produced');
assert.strictEqual(stdout, '');

// stderr should have a syntax error message
assert(syntaxErrorRE.test(stderr), 'stderr incorrect');
assert(syntaxErrorRE.test(stderr), `${syntaxErrorRE} === ${stderr}`);

// stderr should include the filename
assert(stderr.startsWith(file), "stderr doesn't start with the filename");
assert(stderr.startsWith(file), `${stderr} starts with ${file}`);
}));
});
});
Expand All @@ -81,12 +81,12 @@ const notFoundRE = /^Error: Cannot find module/m;
const cmd = [node, ..._args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
// no stdout should be produced
assert.strictEqual(stdout, '', 'stdout produced');
assert.strictEqual(stdout, '');

// stderr should have a module not found error message
assert(notFoundRE.test(stderr), 'stderr incorrect');
assert(notFoundRE.test(stderr), `${notFoundRE} === ${stderr}`);

assert.strictEqual(err.code, 1, `code === ${err.code}`);
assert.strictEqual(err.code, 1);
}));
});
});
Expand All @@ -98,10 +98,10 @@ syntaxArgs.forEach(function(args) {
const c = spawnSync(node, args, { encoding: 'utf8', input: stdin });

// no stdout or stderr should be produced
assert.strictEqual(c.stdout, '', 'stdout produced');
assert.strictEqual(c.stderr, '', 'stderr produced');
assert.strictEqual(c.stdout, '');
assert.strictEqual(c.stderr, '');

assert.strictEqual(c.status, 0, `code === ${c.status}`);
assert.strictEqual(c.status, 0);
});

// should throw if code piped from stdin with --check has bad syntax
Expand All @@ -111,15 +111,15 @@ syntaxArgs.forEach(function(args) {
const c = spawnSync(node, args, { encoding: 'utf8', input: stdin });

// stderr should include '[stdin]' as the filename
assert(c.stderr.startsWith('[stdin]'), "stderr doesn't start with [stdin]");
assert(c.stderr.startsWith('[stdin]'), `${c.stderr} starts with ${stdin}`);

// no stdout or stderr should be produced
assert.strictEqual(c.stdout, '', 'stdout produced');
assert.strictEqual(c.stdout, '');

// stderr should have a syntax error message
assert(syntaxErrorRE.test(c.stderr), 'stderr incorrect');
assert(syntaxErrorRE.test(c.stderr), `${syntaxErrorRE} === ${c.stderr}`);

assert.strictEqual(c.status, 1, `code === ${c.status}`);
assert.strictEqual(c.status, 1);
});

// should throw if -c and -e flags are both passed
Expand All @@ -129,7 +129,7 @@ syntaxArgs.forEach(function(args) {
const cmd = [node, ...args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
assert.strictEqual(err instanceof Error, true);
assert.strictEqual(err.code, 9, `code === ${err.code}`);
assert.strictEqual(err.code, 9);
assert(
stderr.startsWith(
`${node}: either --check or --eval can be used, not both`
Expand Down

0 comments on commit f96745a

Please sign in to comment.