Skip to content

Commit b2ab41e

Browse files
committed
test: increase readline coverage
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]>
1 parent 8aca66a commit b2ab41e

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/parallel/test-readline.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
'use strict';
2+
const common = require('../common');
3+
const { PassThrough } = require('stream');
4+
const readline = require('readline');
5+
const assert = require('assert');
6+
7+
{
8+
const input = new PassThrough();
9+
const rl = readline.createInterface({
10+
terminal: true,
11+
input: input
12+
});
13+
14+
rl.on('line', common.mustCall((data) => {
15+
assert.strictEqual(data, 'abc');
16+
}));
17+
18+
input.end('abc');
19+
}
20+
21+
{
22+
const input = new PassThrough();
23+
const rl = readline.createInterface({
24+
terminal: true,
25+
input: input
26+
});
27+
28+
rl.on('line', common.mustNotCall('must not be called before newline'));
29+
30+
input.write('abc');
31+
}
32+
33+
{
34+
const input = new PassThrough();
35+
const rl = readline.createInterface({
36+
terminal: true,
37+
input: input
38+
});
39+
40+
rl.on('line', common.mustCall((data) => {
41+
assert.strictEqual(data, 'abc');
42+
}));
43+
44+
input.write('abc\n');
45+
}

0 commit comments

Comments
 (0)