From 65ae44585bb5fb7f3c3b39d4e2c0d489422b21d1 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 --- 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