From eaab99e5e2d8e51403db44982becd347e057fdbf Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 2 Feb 2017 11:21:08 -0800 Subject: [PATCH] test: simplify output handling in repl tests Replace .map() + .replace().trim() with a single .replace(). PR-URL: https://github.com/nodejs/node/pull/11124 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Yuta Hiroto Reviewed-By: Italo A. Casas --- test/known_issues/test-repl-require-context.js | 4 +--- test/parallel/test-repl-require-context.js | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/test/known_issues/test-repl-require-context.js b/test/known_issues/test-repl-require-context.js index 2c9195d940e2e4..e7a27f2ca68f6b 100644 --- a/test/known_issues/test-repl-require-context.js +++ b/test/known_issues/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', '']); })); diff --git a/test/parallel/test-repl-require-context.js b/test/parallel/test-repl-require-context.js index 798d6f2db30f49..51a7339773a31e 100644 --- a/test/parallel/test-repl-require-context.js +++ b/test/parallel/test-repl-require-context.js @@ -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', '']); }));