Skip to content

Commit

Permalink
test: increase readline coverage
Browse files Browse the repository at this point in the history
PR-URL: #12761
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
addaleax authored and MylesBorins committed Jul 11, 2017
1 parent cab1285 commit eefa840
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/parallel/test-readline.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';
const common = require('../common');
const { PassThrough } = require('stream');
const readline = require('readline');
const assert = require('assert');

{
const input = new PassThrough();
const rl = readline.createInterface({
terminal: true,
input: input
});

rl.on('line', common.mustCall((data) => {
assert.strictEqual(data, 'abc');
}));

input.end('abc');
}

{
const input = new PassThrough();
const rl = readline.createInterface({
terminal: true,
input: input
});

rl.on('line', common.mustNotCall('must not be called before newline'));

input.write('abc');
}

{
const input = new PassThrough();
const rl = readline.createInterface({
terminal: true,
input: input
});

rl.on('line', common.mustCall((data) => {
assert.strictEqual(data, 'abc');
}));

input.write('abc\n');
}

0 comments on commit eefa840

Please sign in to comment.