Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 16eb078

Browse filesBrowse files
aduh95targos
authored andcommitted
test,readline: improve tab completion coverage
PR-URL: #38465 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 7ce39b8 commit 16eb078
Copy full SHA for 16eb078

File tree

Expand file treeCollapse file tree

1 file changed

+40
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+40
-8
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-readline-tab-complete.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-readline-tab-complete.js
+40-8Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ common.skipIfDumbTerminal();
3131
const width = getStringWidth(char) - 1;
3232

3333
class FakeInput extends EventEmitter {
34-
columns = ((width + 1) * 10 + (lineBreak ? 0 : 10)) * 3
34+
columns = ((width + 1) * 10 + (lineBreak ? 0 : 10)) * 3
3535

36-
write = common.mustCall((data) => {
37-
output += data;
38-
}, 6)
36+
write = common.mustCall((data) => {
37+
output += data;
38+
}, 6)
3939

40-
resume() {}
41-
pause() {}
42-
end() {}
40+
resume() {}
41+
pause() {}
42+
end() {}
4343
}
4444

4545
const fi = new FakeInput();
4646
const rli = new readline.Interface({
4747
input: fi,
4848
output: fi,
4949
terminal: true,
50-
completer: completer
50+
completer: common.mustCallAtLeast(completer),
5151
});
5252

5353
const last = '\r\nFirst group\r\n\r\n' +
@@ -68,3 +68,35 @@ common.skipIfDumbTerminal();
6868
rli.close();
6969
});
7070
});
71+
72+
{
73+
let output = '';
74+
class FakeInput extends EventEmitter {
75+
columns = 80
76+
77+
write = common.mustCall((data) => {
78+
output += data;
79+
}, 1)
80+
81+
resume() {}
82+
pause() {}
83+
end() {}
84+
}
85+
86+
const fi = new FakeInput();
87+
const rli = new readline.Interface({
88+
input: fi,
89+
output: fi,
90+
terminal: true,
91+
completer:
92+
common.mustCallAtLeast((_, cb) => cb(new Error('message'))),
93+
});
94+
95+
rli.on('line', common.mustNotCall());
96+
fi.emit('data', '\t');
97+
queueMicrotask(() => {
98+
assert.match(output, /^Tab completion error: Error: message/);
99+
output = '';
100+
});
101+
rli.close();
102+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.