Skip to content

Commit ea6070b

Browse files
pd4d10targos
authored andcommitted
test: improve coverage of lib/readline.js
PR-URL: #38646 Refs: https://coverage.nodejs.org/coverage-16e00a15deafdad0/lib/readline.js.html#L441 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 96566fc commit ea6070b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/parallel/test-readline-interface.js

+30
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,16 @@ for (let i = 0; i < 12; i++) {
10611061
rli.close();
10621062
}
10631063

1064+
// Calling only the first question callback
1065+
{
1066+
const [rli] = getInterface({ terminal });
1067+
rli.question('foo?', common.mustCall((answer) => {
1068+
assert.strictEqual(answer, 'bar');
1069+
}));
1070+
rli.question('hello?', common.mustNotCall());
1071+
rli.write('bar\n');
1072+
}
1073+
10641074
// Calling the question multiple times
10651075
{
10661076
const [rli] = getInterface({ terminal });
@@ -1329,6 +1339,26 @@ for (let i = 0; i < 12; i++) {
13291339
rli.close();
13301340
}), delay);
13311341
}
1342+
1343+
// Write correctly if paused
1344+
{
1345+
const [rli] = getInterface({ terminal });
1346+
rli.on('line', common.mustCall((line) => {
1347+
assert.strictEqual(line, 'bar');
1348+
}));
1349+
rli.pause();
1350+
rli.write('bar\n');
1351+
assert.strictEqual(rli.paused, false);
1352+
rli.close();
1353+
}
1354+
1355+
// Write undefined
1356+
{
1357+
const [rli] = getInterface({ terminal });
1358+
rli.on('line', common.mustNotCall());
1359+
rli.write();
1360+
rli.close();
1361+
}
13321362
});
13331363

13341364
// Ensure that the _wordLeft method works even for large input

0 commit comments

Comments
 (0)