summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2021-04-27 16:04:24 +0200
committerAntoine du Hamel <duhamelantoine1995@gmail.com>2021-05-02 15:04:57 +0200
commit68e6673224365120f50286169148539c7043efd8 (patch)
treeb213dba65c1265ca7d7c4665408aa966fc094317
parent5cee7cbe02fc7c020d6c17207f406174df79ee66 (diff)
downloadnode-new-68e6673224365120f50286169148539c7043efd8.tar.gz
test,readline: improve tab completion coverage
PR-URL: https://github.com/nodejs/node/pull/38465 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
-rw-r--r--test/parallel/test-readline-tab-complete.js48
1 files changed, 40 insertions, 8 deletions
diff --git a/test/parallel/test-readline-tab-complete.js b/test/parallel/test-readline-tab-complete.js
index 7ccdef1164..c283d446f9 100644
--- a/test/parallel/test-readline-tab-complete.js
+++ b/test/parallel/test-readline-tab-complete.js
@@ -31,15 +31,15 @@ common.skipIfDumbTerminal();
const width = getStringWidth(char) - 1;
class FakeInput extends EventEmitter {
- columns = ((width + 1) * 10 + (lineBreak ? 0 : 10)) * 3
+ columns = ((width + 1) * 10 + (lineBreak ? 0 : 10)) * 3
- write = common.mustCall((data) => {
- output += data;
- }, 6)
+ write = common.mustCall((data) => {
+ output += data;
+ }, 6)
- resume() {}
- pause() {}
- end() {}
+ resume() {}
+ pause() {}
+ end() {}
}
const fi = new FakeInput();
@@ -47,7 +47,7 @@ common.skipIfDumbTerminal();
input: fi,
output: fi,
terminal: true,
- completer: completer
+ completer: common.mustCallAtLeast(completer),
});
const last = '\r\nFirst group\r\n\r\n' +
@@ -68,3 +68,35 @@ common.skipIfDumbTerminal();
rli.close();
});
});
+
+{
+ let output = '';
+ class FakeInput extends EventEmitter {
+ columns = 80
+
+ write = common.mustCall((data) => {
+ output += data;
+ }, 1)
+
+ resume() {}
+ pause() {}
+ end() {}
+ }
+
+ const fi = new FakeInput();
+ const rli = new readline.Interface({
+ input: fi,
+ output: fi,
+ terminal: true,
+ completer:
+ common.mustCallAtLeast((_, cb) => cb(new Error('message'))),
+ });
+
+ rli.on('line', common.mustNotCall());
+ fi.emit('data', '\t');
+ queueMicrotask(() => {
+ assert.match(output, /^Tab completion error: Error: message/);
+ output = '';
+ });
+ rli.close();
+}