Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
}