summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-04-27 17:05:29 +0200
committerAnna Henningsen <anna@addaleax.net>2017-05-03 15:49:48 +0200
commitb2ab41e5ae6213b17de8031771585030aea046e2 (patch)
treeb7c400f59474bc3766498bda63fc56f61fdd51c9 /test
parent8aca66a1f32e436b187e99959c52e112de7147b8 (diff)
downloadandroid-node-v8-b2ab41e5ae6213b17de8031771585030aea046e2.tar.gz
android-node-v8-b2ab41e5ae6213b17de8031771585030aea046e2.tar.bz2
android-node-v8-b2ab41e5ae6213b17de8031771585030aea046e2.zip
test: increase readline coverage
PR-URL: https://github.com/nodejs/node/pull/12761 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-readline.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/parallel/test-readline.js b/test/parallel/test-readline.js
new file mode 100644
index 0000000000..62a4fe6f48
--- /dev/null
+++ b/test/parallel/test-readline.js
@@ -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');
+}