Skip to content

Commit e11cad6

Browse files
committed
fix test
1 parent 75bace0 commit e11cad6

File tree

2 files changed

+47
-103
lines changed

2 files changed

+47
-103
lines changed

test/parallel/test-repl-eval-promises.js

Lines changed: 0 additions & 103 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const repl = require('repl');
5+
const ArrayStream = require('../common/arraystream');
6+
const assert = require('assert');
7+
8+
const completionTests = [
9+
{ send: 'Promise.reject().' },
10+
{ send: 'let p = Promise.reject().' },
11+
{ send: 'Promise.resolve().' },
12+
{ send: 'Promise.resolve().then(() => {}).' },
13+
{ send: `async function f() {throw new Error('test');}; f().` },
14+
{ send: `async function f() {}; f().` },
15+
];
16+
17+
(async function() {
18+
await runReplCompleteTests(completionTests);
19+
})().then(common.mustCall());
20+
21+
async function runReplCompleteTests(tests) {
22+
const input = new ArrayStream();
23+
const output = new ArrayStream();
24+
25+
const replServer = repl.start({
26+
prompt: '',
27+
input,
28+
output: output,
29+
allowBlockingCompletions: true,
30+
terminal: true
31+
});
32+
33+
replServer._domain.on('error', (e) => {
34+
assert.fail(`Error in REPL domain: ${e}`);
35+
});
36+
for (const { send } of tests) {
37+
replServer.complete(
38+
send,
39+
common.mustCall((error, data) => {
40+
assert.strictEqual(error, null);
41+
assert.strictEqual(data.length, 2);
42+
assert.strictEqual(typeof data[1], 'string');
43+
assert.ok(send.includes(data[1]));
44+
})
45+
);
46+
}
47+
}

0 commit comments

Comments
 (0)