Skip to content

Commit 16eb078

Browse files
aduh95targos
authored andcommitted
test,readline: improve tab completion coverage
PR-URL: #38465 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 7ce39b8 commit 16eb078

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

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

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ common.skipIfDumbTerminal();
3131
constwidth=getStringWidth(char)-1;
3232

3333
classFakeInputextendsEventEmitter{
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
constfi=newFakeInput();
4646
constrli=newreadline.Interface({
4747
input: fi,
4848
output: fi,
4949
terminal: true,
50-
completer: completer
50+
completer: common.mustCallAtLeast(completer),
5151
});
5252

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

0 commit comments

Comments
(0)