Skip to content

Commit

Permalink
test: increase coverage for readline
Browse files Browse the repository at this point in the history
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: #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 <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Lxxyx authored and danielleadams committed Dec 7, 2020
1 parent bef550a commit fbcb72a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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: '' });
Expand Down

0 comments on commit fbcb72a

Please sign in to comment.