Skip to content

Commit 554f8af

Browse files
committed
repl: add tests
1 parent 3339f62 commit 554f8af

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
const repl = require('repl');
3+
const { describe, it } = require("node:test");
4+
const ArrayStream = require('../common/arraystream');
5+
const assert = require('assert');
6+
const outputStream = new ArrayStream();
7+
let accum = '';
8+
outputStream.write = (data) => accum += data.replace('\r', '');
9+
10+
function prepareREPL() {
11+
const replServer = repl.start({
12+
prompt: '',
13+
input: new ArrayStream(),
14+
output: outputStream,
15+
allowBlockingCompletions: true,
16+
});
17+
18+
19+
return replServer;
20+
}
21+
22+
23+
describe('REPL tab completion without side effects', () => {
24+
const code = [
25+
'typeof Reflect.construct',
26+
'typeof Reflect.const',
27+
];
28+
29+
it(`should return values `, async () => {
30+
const { replServer, input } = prepareREPL();
31+
input.run(code);
32+
assert.strictEqual(accum, '\'function\'\n\'undefined\'\n');
33+
});
34+
});

0 commit comments

Comments
 (0)