Skip to content

Commit f92f9c3

Browse files
committed
readline: simplify interface test code
1 parent dabbe89 commit f92f9c3

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

test/parallel/test-readline-interface.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,14 @@ function isWarned(emitter) {
179179
// character
180180
fi = new FakeInput();
181181
rli = new readline.Interface({ input: fi, output: fi, terminal: true });
182-
expectedLines = ['\t'];
183-
callCount = 0;
182+
called = false;
184183
rli.on('line', function(line) {
185-
assert.equal(line, expectedLines[callCount]);
186-
callCount++;
184+
assert.equal(line, '\t');
185+
called = true;
187186
});
188187
fi.emit('data', '\t');
189188
fi.emit('data', '\n');
190-
assert.equal(callCount, expectedLines.length);
189+
assert.ok(called);
191190
rli.close();
192191

193192
// \t does not become part of the input when there is a completer function
@@ -201,15 +200,14 @@ function isWarned(emitter) {
201200
terminal: true,
202201
completer: completer
203202
});
204-
expectedLines = ['foo'];
205-
callCount = 0;
203+
called = false;
206204
rli.on('line', function(line) {
207-
assert.equal(line, expectedLines[callCount]);
208-
callCount++;
205+
assert.equal(line, 'foo');
206+
called = true;
209207
});
210208
fi.emit('data', '\tfo\to\t');
211209
fi.emit('data', '\n');
212-
assert.equal(callCount, expectedLines.length);
210+
assert.ok(called);
213211
rli.close();
214212

215213
// constructor throws if completer is not a function or undefined

0 commit comments

Comments
 (0)