Skip to content

Commit ff1b432

Browse files
juanarboltargos
authored andcommitted
test: refactor test-readline-interface to be shorter
PR-URL: #38691 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 8eea317 commit ff1b432

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

test/parallel/test-readline-interface.js

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -87,34 +87,16 @@ function assertCursorRowsAndCols(rli, rows, cols) {
8787
const input = new FakeInput();
8888

8989
// Constructor throws if completer is not a function or undefined
90-
assert.throws(() => {
91-
readline.createInterface({
92-
input,
93-
completer: 'string is not valid'
94-
});
95-
}, {
96-
name: 'TypeError',
97-
code: 'ERR_INVALID_ARG_VALUE'
98-
});
99-
100-
assert.throws(() => {
101-
readline.createInterface({
102-
input,
103-
completer: ''
104-
});
105-
}, {
106-
name: 'TypeError',
107-
code: 'ERR_INVALID_ARG_VALUE'
108-
});
109-
110-
assert.throws(() => {
111-
readline.createInterface({
112-
input,
113-
completer: false
90+
['not an array', 123, 123n, {}, true, Symbol(), null].forEach((invalid) => {
91+
assert.throws(() => {
92+
readline.createInterface({
93+
input,
94+
completer: invalid
95+
});
96+
}, {
97+
name: 'TypeError',
98+
code: 'ERR_INVALID_ARG_VALUE'
11499
});
115-
}, {
116-
name: 'TypeError',
117-
code: 'ERR_INVALID_ARG_VALUE'
118100
});
119101

120102
// Constructor throws if history is not an array

0 commit comments

Comments
 (0)