Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[squash] use regex for control code + prompt stripping
  • Loading branch information
addaleax committed Oct 20, 2016
commit d19782764698a431e0558a56bda98455d7c8f884
10 changes: 3 additions & 7 deletions test/parallel/test-repl-.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const repl = require('repl');
// \u001b[0J - Clear screen
// \u001b[3G - Moves the cursor to 3rd column
const terminalCode = '\u001b[1G\u001b[0J> \u001b[3G';
const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g');

function run({input, output, event, checkTerminalCodes = true}) {
const stream = new common.ArrayStream();
Expand All @@ -33,13 +34,8 @@ function run({input, output, event, checkTerminalCodes = true}) {
replServer.close();

if (!checkTerminalCodes) {
while (found.includes(terminalCode))
found = found.replace(terminalCode, '');
while (expected.includes(terminalCode))
expected = expected.replace(terminalCode, '');

found = found.replace(/\n/g, '');
expected = expected.replace(/\n/g, '');
found = found.replace(terminalCodeRegex, '').replace(/\n/g, '');
expected = expected.replace(terminalCodeRegex, '').replace(/\n/g, '');
}

assert.strictEqual(found, expected);
Expand Down