From cbcf7945628fd7f77f3af3b1cdf43632ebf562a5 Mon Sep 17 00:00:00 2001 From: Erick Wendel Date: Sat, 5 Feb 2022 05:08:25 -0300 Subject: [PATCH] readline: improve code coverage for readline promises PR-URL: https://github.com/nodejs/node/pull/41817 Refs: https://coverage.nodejs.org/coverage-7123a00b03a90862/lib/readline/promises.js.html#L42 Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum Reviewed-By: Antoine du Hamel Reviewed-By: Mestery Reviewed-By: Luigi Pinca Reviewed-By: Zijian Liu --- .../test-readline-promises-interface.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/parallel/test-readline-promises-interface.js b/test/parallel/test-readline-promises-interface.js index e4bf483c3dc851..cf0543d7d255f7 100644 --- a/test/parallel/test-readline-promises-interface.js +++ b/test/parallel/test-readline-promises-interface.js @@ -797,6 +797,24 @@ for (let i = 0; i < 12; i++) { fi.emit('data', 'asdf\n'); } + // Ensure that options.signal.removeEventListener was called + { + const ac = new AbortController(); + const signal = ac.signal; + const [rli] = getInterface({ terminal }); + signal.removeEventListener = common.mustCall( + (event, onAbortFn) => { + assert.strictEqual(event, 'abort'); + assert.strictEqual(onAbortFn.name, 'onAbort'); + }); + + rli.question('hello?', { signal }).then(common.mustCall()); + + rli.write('bar\n'); + ac.abort(); + rli.close(); + } + // Sending a blank line { const [rli, fi] = getInterface({ terminal });