mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
test: stricten readline keypress failure test condition
This verifies that the thrown error is the expected one. That was not tested before. PR-URL: https://github.com/nodejs/node/pull/31300 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 file changed
+9
-4
@@ -561,15 +561,20 @@ function isWarned(emitter) {
|
||||
{ input: fi, output: fi, terminal: true }
|
||||
);
|
||||
const keys = [];
|
||||
const err = new Error('bad thing happened');
|
||||
fi.on('keypress', function(key) {
|
||||
keys.push(key);
|
||||
if (key === 'X') {
|
||||
throw new Error('bad thing happened');
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
try {
|
||||
fi.emit('data', 'fooX');
|
||||
} catch { }
|
||||
assert.throws(
|
||||
() => fi.emit('data', 'fooX'),
|
||||
(e) => {
|
||||
assert.strictEqual(e, err);
|
||||
return true;
|
||||
}
|
||||
);
|
||||
fi.emit('data', 'bar');
|
||||
assert.strictEqual(keys.join(''), 'fooXbar');
|
||||
rli.close();
|
||||
|
||||
Reference in new issue
Block a user