Skip to content

Commit

Permalink
test: refactor test-repl-tab-complete
Browse files Browse the repository at this point in the history
* Add check for `data` object in tab completion callback
* Replace `.indexOf()` with `.startsWith()` where appropriate

PR-URL: #10879
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and MylesBorins committed Mar 9, 2017
1 parent 68fc4d3 commit 38b123c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions test/parallel/test-repl-tab-complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -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]);
}
Expand Down

0 comments on commit 38b123c

Please sign in to comment.