MCPcopy Index your code
hub / github.com/nodejs/node / addKeyIntervalTest

Function addKeyIntervalTest

test/parallel/test-readline-keys.js:52–83  ·  view source on GitHub ↗
(sequences, expectedKeys, interval = 550,
                            assertDelay = 550)

Source from the content-addressed store, hash-verified

50// where noop is a terminal function(() => {}).
51
52function addKeyIntervalTest(sequences, expectedKeys, interval = 550,
53 assertDelay = 550) {
54 const fn = common.mustCall((next) => common.mustCall(() => {
55
56 if (!Array.isArray(sequences)) {
57 sequences = [ sequences ];
58 }
59
60 if (!Array.isArray(expectedKeys)) {
61 expectedKeys = [ expectedKeys ];
62 }
63
64 expectedKeys = expectedKeys.map(extend);
65
66 const keys = [];
67 fi.on('keypress', (s, k) => keys.push(k));
68
69 const emitKeys = common.mustCallAtLeast(([head, ...tail]) => {
70 if (head) {
71 fi.write(head);
72 setTimeout(() => emitKeys(tail), interval);
73 } else {
74 setTimeout(common.mustCall(() => {
75 next();
76 assert.deepStrictEqual(keys, expectedKeys);
77 }), assertDelay);
78 }
79 });
80 emitKeys(sequences);
81 }));
82 return fn;
83}
84
85// Regular alphanumerics
86addTest('io.JS', [

Callers 1

Calls 7

emitKeysFunction · 0.85
nextFunction · 0.70
mapMethod · 0.65
setTimeoutFunction · 0.50
onMethod · 0.45
pushMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…