summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-07-13 19:22:46 -0400
committerMichaƫl Zasso <targos@protonmail.com>2019-07-20 11:13:06 +0200
commit4a7e20ff81770916c38def86106f469d444a65d7 (patch)
treee5b77d6d1ea17709cc7e7f59e5f3cbc46ddecc16 /test
parent0f5af4430471ff157e8db23536f2c7fda7f449b2 (diff)
downloadandroid-node-v8-4a7e20ff81770916c38def86106f469d444a65d7.tar.gz
android-node-v8-4a7e20ff81770916c38def86106f469d444a65d7.tar.bz2
android-node-v8-4a7e20ff81770916c38def86106f469d444a65d7.zip
readline: expose stream API in moveCursor()
This commit adds an optional callback to moveCursor(), 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')
-rw-r--r--test/parallel/test-readline-csi.js20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/parallel/test-readline-csi.js b/test/parallel/test-readline-csi.js
index becd4cd8d4..b89990d594 100644
--- a/test/parallel/test-readline-csi.js
+++ b/test/parallel/test-readline-csi.js
@@ -83,10 +83,28 @@ assert.strictEqual(readline.clearLine(undefined, 0, common.mustCall()), true);
[1, -1, '\x1b[1C\x1b[1A'],
].forEach((set) => {
writable.data = '';
- readline.moveCursor(writable, set[0], set[1]);
+ assert.strictEqual(readline.moveCursor(writable, set[0], set[1]), true);
+ assert.deepStrictEqual(writable.data, set[2]);
+ writable.data = '';
+ assert.strictEqual(
+ readline.moveCursor(writable, set[0], set[1], common.mustCall()),
+ true
+ );
assert.deepStrictEqual(writable.data, set[2]);
});
+// Verify that moveCursor() throws on invalid callback.
+assert.throws(() => {
+ readline.moveCursor(writable, 1, 1, null);
+}, /ERR_INVALID_CALLBACK/);
+
+// Verify that moveCursor() does not throw on null or undefined stream.
+assert.strictEqual(readline.moveCursor(null, 1, 1), true);
+assert.strictEqual(readline.moveCursor(undefined, 1, 1), true);
+assert.strictEqual(readline.moveCursor(null, 1, 1, common.mustCall()), true);
+assert.strictEqual(readline.moveCursor(undefined, 1, 1, common.mustCall()),
+ true);
+
// Undefined or null as stream should not throw.
readline.cursorTo(null);
readline.cursorTo();