Skip to content

Commit

Permalink
readline: simplify interface test code
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed May 30, 2015
1 parent dabbe89 commit f92f9c3
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions test/parallel/test-readline-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,14 @@ function isWarned(emitter) {
// character
fi = new FakeInput();
rli = new readline.Interface({ input: fi, output: fi, terminal: true });
expectedLines = ['\t'];
callCount = 0;
called = false;
rli.on('line', function(line) {
assert.equal(line, expectedLines[callCount]);
callCount++;
assert.equal(line, '\t');
called = true;
});
fi.emit('data', '\t');
fi.emit('data', '\n');
assert.equal(callCount, expectedLines.length);
assert.ok(called);
rli.close();

// \t does not become part of the input when there is a completer function
Expand All @@ -201,15 +200,14 @@ function isWarned(emitter) {
terminal: true,
completer: completer
});
expectedLines = ['foo'];
callCount = 0;
called = false;
rli.on('line', function(line) {
assert.equal(line, expectedLines[callCount]);
callCount++;
assert.equal(line, 'foo');
called = true;
});
fi.emit('data', '\tfo\to\t');
fi.emit('data', '\n');
assert.equal(callCount, expectedLines.length);
assert.ok(called);
rli.close();

// constructor throws if completer is not a function or undefined
Expand Down

0 comments on commit f92f9c3

Please sign in to comment.