Skip to content

Commit 3fa4356

Browse files
committed
fix test
1 parent 75bace0 commit 3fa4356

File tree

2 files changed

+46
-103
lines changed

2 files changed

+46
-103
lines changed

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

Lines changed: 0 additions & 103 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
for (const { send } of tests) {
23+
const input = new ArrayStream();
24+
const output = new ArrayStream();
25+
26+
const replServer = repl.start({
27+
prompt: '',
28+
input,
29+
output: output,
30+
allowBlockingCompletions: true,
31+
terminal: true
32+
});
33+
34+
replServer._domain.on('error', assert.ifError);
35+
36+
replServer.complete(
37+
send,
38+
common.mustCall((error, data) => {
39+
assert.strictEqual(error, null);
40+
assert.strictEqual(data.length, 2);
41+
assert.strictEqual(typeof data[1], 'string');
42+
assert.ok(send.includes(data[1]));
43+
})
44+
);
45+
}
46+
}

0 commit comments

Comments
 (0)