test: increase coverage for readline

1. test call readline.Interface without new should return instance
Refs: https://coverage.nodejs.org/coverage-f7dd330ba0e7bfa9/lib/readline.js.html#L101

2. test keypress ctrl + c should close readline interface
Refs: https://coverage.nodejs.org/coverage-f7dd330ba0e7bfa9/lib/readline.js.html#L891

PR-URL: https://github.com/nodejs/node/pull/36389
Refs: https://coverage.nodejs.org/coverage-f7dd330ba0e7bfa9/lib/readline.js.html#L101
Refs: https://coverage.nodejs.org/coverage-f7dd330ba0e7bfa9/lib/readline.js.html#L891
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Zijian Liu authored and Michaël Zasso committed 2021-05-01 09:44:36 +02:00
1 parent f515156fab
commit 5fc0f5eabb
1 file changed
+13
+13
View File
@@ -63,6 +63,12 @@ function assertCursorRowsAndCols(rli, rows, cols) {
assert.strictEqual(cursorPos.cols, cols);
}
{
const input = new FakeInput();
const rl = readline.Interface({ input });
assert(rl instanceof readline.Interface);
}
[
undefined,
50,
@@ -657,6 +663,13 @@ function assertCursorRowsAndCols(rli, rows, cols) {
rli.close();
}
// Close readline interface
{
const [rli, fi] = getInterface({ terminal: true, prompt: '' });
fi.emit('keypress', '.', { ctrl: true, name: 'c' });
assert(rli.closed);
}
// Multi-line input cursor position
{
const [rli, fi] = getInterface({ terminal: true, prompt: '' });