Permalink
Browse files

test: simplify output handling in repl tests

Replace .map() + .replace().trim() with a single .replace().

PR-URL: #11124
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
  • Loading branch information...
Trott authored and italoacasas committed Feb 2, 2017
1 parent ce3dcca commit fbd495583e02430fa87f1e9204bacb8724f3838f
Showing with 2 additions and 7 deletions.
  1. +1 −3 test/known_issues/test-repl-require-context.js
  2. +1 −4 test/parallel/test-repl-require-context.js
@@ -19,9 +19,7 @@ outputStream.setEncoding('utf8');
outputStream.on('data', (data) => output += data);
r.on('exit', common.mustCall(() => {
- const results = output.split('\n').map((line) => {
- return line.replace(/\w*>\w*/, '').trim();
- });
+ const results = output.replace(/^> /mg, '').split('\n');
assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']);
}));
@@ -14,10 +14,7 @@ child.stdout.on('data', (data) => {
});
child.on('exit', common.mustCall(() => {
- const results = output.split('\n').map((line) => {
- return line.replace(/\w*>\w*/, '').trim();
- });
-
+ const results = output.replace(/^> /mg, '').split('\n');
assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']);
}));

0 comments on commit fbd4955

Please sign in to comment.