diff options
author | Rich Trott <rtrott@gmail.com> | 2017-01-18 11:00:51 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-01-20 20:38:40 -0800 |
commit | b5474c8cee47cda7ca0e3711bd39ebcd8a6d8964 (patch) | |
tree | bbee4a29ce5bc8624468a3beaaba751d71dbd988 | |
parent | ba776b3a56642d4cade5fa26c27c654bb6dde759 (diff) | |
download | android-node-v8-b5474c8cee47cda7ca0e3711bd39ebcd8a6d8964.tar.gz android-node-v8-b5474c8cee47cda7ca0e3711bd39ebcd8a6d8964.tar.bz2 android-node-v8-b5474c8cee47cda7ca0e3711bd39ebcd8a6d8964.zip |
test: refactor test-repl-tab-complete
* Add check for `data` object in tab completion callback
* Replace `.indexOf()` with `.startsWith()` where appropriate
PR-URL: https://github.com/nodejs/node/pull/10879
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
-rw-r--r-- | test/parallel/test-repl-tab-complete.js | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js index 835634b0a4..1a1a2a8628 100644 --- a/test/parallel/test-repl-tab-complete.js +++ b/test/parallel/test-repl-tab-complete.js @@ -231,6 +231,7 @@ putIn.run([ testMe.complete('proxy.', common.mustCall(function(error, data) { assert.strictEqual(error, null); + assert(Array.isArray(data)); })); // Make sure tab completion does not include integer members of an Array @@ -307,9 +308,7 @@ const testCustomCompleterSyncMode = repl.start({ input: putIn, output: putIn, completer: function completer(line) { - const hits = customCompletions.filter((c) => { - return c.indexOf(line) === 0; - }); + const hits = customCompletions.filter((c) => c.startsWith(line)); // Show all completions if none found. return [hits.length ? hits : customCompletions, line]; } @@ -339,9 +338,7 @@ const testCustomCompleterAsyncMode = repl.start({ input: putIn, output: putIn, completer: function completer(line, callback) { - const hits = customCompletions.filter((c) => { - return c.indexOf(line) === 0; - }); + const hits = customCompletions.filter((c) => c.startsWith(line)); // Show all completions if none found. callback(null, [hits.length ? hits : customCompletions, line]); } |