-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: add escapeCodeTimeout as an option to createInterface
PR-URL: #19780 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
- Loading branch information
1 parent
c2dab8e
commit bda45a5
Showing
3 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/parallel/test-readline-interface-escapecodetimeout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
|
||
// This test ensures that the escapeCodeTimeout option set correctly | ||
|
||
const assert = require('assert'); | ||
const readline = require('readline'); | ||
const EventEmitter = require('events').EventEmitter; | ||
|
||
class FakeInput extends EventEmitter { | ||
resume() {} | ||
pause() {} | ||
write() {} | ||
end() {} | ||
} | ||
|
||
{ | ||
const fi = new FakeInput(); | ||
const rli = new readline.Interface({ | ||
input: fi, | ||
output: fi, | ||
escapeCodeTimeout: 50 | ||
}); | ||
assert.strictEqual(rli.escapeCodeTimeout, 50); | ||
rli.close(); | ||
} | ||
|
||
[ | ||
null, | ||
{}, | ||
NaN, | ||
'50' | ||
].forEach((invalidInput) => { | ||
common.expectsError(() => { | ||
const fi = new FakeInput(); | ||
const rli = new readline.Interface({ | ||
input: fi, | ||
output: fi, | ||
escapeCodeTimeout: invalidInput | ||
}); | ||
rli.close(); | ||
}, { | ||
type: TypeError, | ||
code: 'ERR_INVALID_OPT_VALUE' | ||
}); | ||
}); |