| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 18c4933 commit d6786d2
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,35 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const repl = require('repl'); | ||
| 5 | + const inputStream = new common.ArrayStream(); | ||
| 6 | + const outputStream = new common.ArrayStream(); | ||
| 7 | + const input = ['var foo = {', '};', 'foo;']; | ||
| 8 | + let output = ''; | ||
| 9 | + | ||
| 10 | + outputStream.write = (data) => { output += data.replace('\r', ''); }; | ||
| 11 | + | ||
| 12 | + const r = repl.start({ | ||
| 13 | + prompt: '', | ||
| 14 | + input: inputStream, | ||
| 15 | + output: outputStream, | ||
| 16 | + terminal: true, | ||
| 17 | + useColors: false | ||
| 18 | + }); | ||
| 19 | + | ||
| 20 | + r.on('exit', common.mustCall(() => { | ||
| 21 | + const actual = output.split('\n'); | ||
| 22 | + | ||
| 23 | + // Validate the output, which contains terminal escape codes. | ||
| 24 | + assert.strictEqual(actual.length, 6); | ||
| 25 | + assert.ok(actual[0].endsWith(input[0])); | ||
| 26 | + assert.ok(actual[1].includes('... ')); | ||
| 27 | + assert.ok(actual[1].endsWith(input[1])); | ||
| 28 | + assert.strictEqual(actual[2], 'undefined'); | ||
| 29 | + assert.ok(actual[3].endsWith(input[2])); | ||
| 30 | + assert.strictEqual(actual[4], '{}'); | ||
| 31 | + // Ignore the last line, which is nothing but escape codes. | ||
| 32 | + })); | ||
| 33 | + | ||
| 34 | + inputStream.run(input); | ||
| 35 | + r.close(); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments