mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
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>
This commit is contained in:
1 parent
52f3837518
commit
bfe02b8808
1 file changed
+40
-8
@@ -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();
|
||||
}
|
||||
Reference in new issue
Block a user