From 354b0bef0298e0ff70df07816880919b7b63947c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Arboleda?= Date: Fri, 14 May 2021 18:25:35 -0500 Subject: [PATCH] test: refactor `test-readline-interface` to be shorter PR-URL: https://github.com/nodejs/node/pull/38691 Reviewed-By: Anna Henningsen Reviewed-By: Darshan Sen Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-readline-interface.js | 36 ++++++------------------ 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index a3020181b3532e..5e05610aeae8f4 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -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