Skip to content

Commit

Permalink
test: refactor test-readline-interface to be shorter
Browse files Browse the repository at this point in the history
PR-URL: #38691
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
juanarbol authored and jasnell committed May 17, 2021
1 parent cbe0f09 commit 354b0be
Showing 1 changed file with 9 additions and 27 deletions.
36 changes: 9 additions & 27 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,34 +87,16 @@ function assertCursorRowsAndCols(rli, rows, cols) {
const input = new FakeInput();

// Constructor throws if completer is not a function or undefined
assert.throws(() => {
readline.createInterface({
input,
completer: 'string is not valid'
});
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE'
});

assert.throws(() => {
readline.createInterface({
input,
completer: ''
});
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE'
});

assert.throws(() => {
readline.createInterface({
input,
completer: false
['not an array', 123, 123n, {}, true, Symbol(), null].forEach((invalid) => {
assert.throws(() => {
readline.createInterface({
input,
completer: invalid
});
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE'
});
}, {
name: 'TypeError',
code: 'ERR_INVALID_ARG_VALUE'
});

// Constructor throws if history is not an array
Expand Down

0 comments on commit 354b0be

Please sign in to comment.