({ input: inputStr, output: outputStr, event, checkTerminalCodes = true })
| 15 | const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g'); |
| 16 | |
| 17 | function run({ input: inputStr, output: outputStr, event, checkTerminalCodes = true }) { |
| 18 | let expected = |
| 19 | `${terminalCode}.editor\n` + |
| 20 | '// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n' + |
| 21 | `${inputStr}${outputStr}\n${terminalCode}`; |
| 22 | |
| 23 | const { replServer, input, output } = startNewREPLServer({ |
| 24 | prompt: '> ', |
| 25 | terminal: true, |
| 26 | useColors: false |
| 27 | }); |
| 28 | |
| 29 | input.emit('data', '.editor\n'); |
| 30 | input.emit('data', inputStr); |
| 31 | replServer.write('', event); |
| 32 | replServer.close(); |
| 33 | |
| 34 | let found = output.accumulator; |
| 35 | if (!checkTerminalCodes) { |
| 36 | found = found.replace(terminalCodeRegex, '').replace(/\n/g, ''); |
| 37 | expected = expected.replace(terminalCodeRegex, '').replace(/\n/g, ''); |
| 38 | } |
| 39 | |
| 40 | assert.strictEqual(found, expected); |
| 41 | } |
| 42 | |
| 43 | const tests = [ |
| 44 | { |
no test coverage detected