summaryrefslogtreecommitdiff
path: root/test/parallel/test-readline-csi.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-07-13 20:10:17 -0400
committercjihrig <cjihrig@gmail.com>2019-07-16 10:03:19 -0400
commit462f43824f6af577bde27da76d9f33365eddcfe7 (patch)
tree12c9d41f2b0856a23a265f9227518f03bf3703e5 /test/parallel/test-readline-csi.js
parent795c7482f24c0c2f1b2db8d004b03ea373b6381b (diff)
downloadandroid-node-v8-462f43824f6af577bde27da76d9f33365eddcfe7.tar.gz
android-node-v8-462f43824f6af577bde27da76d9f33365eddcfe7.tar.bz2
android-node-v8-462f43824f6af577bde27da76d9f33365eddcfe7.zip
readline: expose stream API in cursorTo()
This commit adds an optional callback to cursorTo(), which is passed to the stream's write() method. It also exposes the return value of write(). PR-URL: https://github.com/nodejs/node/pull/28674 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test/parallel/test-readline-csi.js')
-rw-r--r--test/parallel/test-readline-csi.js23
1 files changed, 17 insertions, 6 deletions
diff --git a/test/parallel/test-readline-csi.js b/test/parallel/test-readline-csi.js
index b89990d594..1556892cff 100644
--- a/test/parallel/test-readline-csi.js
+++ b/test/parallel/test-readline-csi.js
@@ -106,15 +106,17 @@ assert.strictEqual(readline.moveCursor(undefined, 1, 1, common.mustCall()),
true);
// Undefined or null as stream should not throw.
-readline.cursorTo(null);
-readline.cursorTo();
+assert.strictEqual(readline.cursorTo(null), true);
+assert.strictEqual(readline.cursorTo(), true);
+assert.strictEqual(readline.cursorTo(null, 1, 1, common.mustCall()), true);
+assert.strictEqual(readline.cursorTo(undefined, 1, 1, common.mustCall()), true);
writable.data = '';
-readline.cursorTo(writable, 'a');
+assert.strictEqual(readline.cursorTo(writable, 'a'), true);
assert.strictEqual(writable.data, '');
writable.data = '';
-readline.cursorTo(writable, 'a', 'b');
+assert.strictEqual(readline.cursorTo(writable, 'a', 'b'), true);
assert.strictEqual(writable.data, '');
writable.data = '';
@@ -128,9 +130,18 @@ common.expectsError(
assert.strictEqual(writable.data, '');
writable.data = '';
-readline.cursorTo(writable, 1, 'a');
+assert.strictEqual(readline.cursorTo(writable, 1, 'a'), true);
assert.strictEqual(writable.data, '\x1b[2G');
writable.data = '';
-readline.cursorTo(writable, 1, 2);
+assert.strictEqual(readline.cursorTo(writable, 1, 2), true);
assert.strictEqual(writable.data, '\x1b[3;2H');
+
+writable.data = '';
+assert.strictEqual(readline.cursorTo(writable, 1, 2, common.mustCall()), true);
+assert.strictEqual(writable.data, '\x1b[3;2H');
+
+// Verify that cursorTo() throws on invalid callback.
+assert.throws(() => {
+ readline.cursorTo(writable, 1, 1, null);
+}, /ERR_INVALID_CALLBACK/);