mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
test: improve coverage of lib/readline.js
PR-URL: https://github.com/nodejs/node/pull/38646 Refs: https://coverage.nodejs.org/coverage-16e00a15deafdad0/lib/readline.js.html#L441 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
96566fc696
commit
ea6070b0e8
1 file changed
+30
@@ -1061,6 +1061,16 @@ for (let i = 0; i < 12; i++) {
|
||||
rli.close();
|
||||
}
|
||||
|
||||
// Calling only the first question callback
|
||||
{
|
||||
const [rli] = getInterface({ terminal });
|
||||
rli.question('foo?', common.mustCall((answer) => {
|
||||
assert.strictEqual(answer, 'bar');
|
||||
}));
|
||||
rli.question('hello?', common.mustNotCall());
|
||||
rli.write('bar\n');
|
||||
}
|
||||
|
||||
// Calling the question multiple times
|
||||
{
|
||||
const [rli] = getInterface({ terminal });
|
||||
@@ -1329,6 +1339,26 @@ for (let i = 0; i < 12; i++) {
|
||||
rli.close();
|
||||
}), delay);
|
||||
}
|
||||
|
||||
// Write correctly if paused
|
||||
{
|
||||
const [rli] = getInterface({ terminal });
|
||||
rli.on('line', common.mustCall((line) => {
|
||||
assert.strictEqual(line, 'bar');
|
||||
}));
|
||||
rli.pause();
|
||||
rli.write('bar\n');
|
||||
assert.strictEqual(rli.paused, false);
|
||||
rli.close();
|
||||
}
|
||||
|
||||
// Write undefined
|
||||
{
|
||||
const [rli] = getInterface({ terminal });
|
||||
rli.on('line', common.mustNotCall());
|
||||
rli.write();
|
||||
rli.close();
|
||||
}
|
||||
});
|
||||
|
||||
// Ensure that the _wordLeft method works even for large input
|
||||
|
||||
Reference in new issue
Block a user