mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
test: refactor test-readline-keys
* replace `util._extend()` with `Object.assign()` * extract repeated map function to a single instance * remove unneeded truthiness-check ternary on Objects Backport-PR-URL: https://github.com/nodejs/node/pull/16947 PR-URL: https://github.com/nodejs/node/pull/11281 Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 parent
26c4224614
commit
7e9779aade
1 file changed
+6
-7
@@ -3,7 +3,6 @@ const common = require('../common');
|
||||
const PassThrough = require('stream').PassThrough;
|
||||
const assert = require('assert');
|
||||
const inherits = require('util').inherits;
|
||||
const extend = require('util')._extend;
|
||||
const Interface = require('readline').Interface;
|
||||
|
||||
|
||||
@@ -12,6 +11,10 @@ function FakeInput() {
|
||||
}
|
||||
inherits(FakeInput, PassThrough);
|
||||
|
||||
function extend(k) {
|
||||
return Object.assign({ ctrl: false, meta: false, shift: false }, k);
|
||||
}
|
||||
|
||||
|
||||
const fi = new FakeInput();
|
||||
const fo = new FakeInput();
|
||||
@@ -32,9 +35,7 @@ function addTest(sequences, expectedKeys) {
|
||||
expectedKeys = [ expectedKeys ];
|
||||
}
|
||||
|
||||
expectedKeys = expectedKeys.map(function(k) {
|
||||
return k ? extend({ ctrl: false, meta: false, shift: false }, k) : k;
|
||||
});
|
||||
expectedKeys = expectedKeys.map(extend);
|
||||
|
||||
keys = [];
|
||||
|
||||
@@ -65,9 +66,7 @@ const addKeyIntervalTest = (sequences, expectedKeys, interval = 550,
|
||||
expectedKeys = [ expectedKeys ];
|
||||
}
|
||||
|
||||
expectedKeys = expectedKeys.map(function(k) {
|
||||
return k ? extend({ ctrl: false, meta: false, shift: false }, k) : k;
|
||||
});
|
||||
expectedKeys = expectedKeys.map(extend);
|
||||
|
||||
const keys = [];
|
||||
fi.on('keypress', (s, k) => keys.push(k));
|
||||
|
||||
Reference in new issue
Block a user