Skip to content

Commit 2509a94

Browse files
Trottitaloacasas
authored andcommittedJan 25, 2017
test: refactor test-repl-tab-complete
* Add check for `data` object in tab completion callback * Replace `.indexOf()` with `.startsWith()` where appropriate PR-URL: nodejs#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]>
1 parent a239d53 commit 2509a94

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed
 

‎test/parallel/test-repl-tab-complete.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ putIn.run([
231231

232232
testMe.complete('proxy.', common.mustCall(function(error, data) {
233233
assert.strictEqual(error, null);
234+
assert(Array.isArray(data));
234235
}));
235236

236237
// Make sure tab completion does not include integer members of an Array
@@ -307,9 +308,7 @@ const testCustomCompleterSyncMode = repl.start({
307308
input: putIn,
308309
output: putIn,
309310
completer: function completer(line) {
310-
const hits = customCompletions.filter((c) => {
311-
return c.indexOf(line) === 0;
312-
});
311+
const hits = customCompletions.filter((c) => c.startsWith(line));
313312
// Show all completions if none found.
314313
return [hits.length ? hits : customCompletions, line];
315314
}
@@ -339,9 +338,7 @@ const testCustomCompleterAsyncMode = repl.start({
339338
input: putIn,
340339
output: putIn,
341340
completer: function completer(line, callback) {
342-
const hits = customCompletions.filter((c) => {
343-
return c.indexOf(line) === 0;
344-
});
341+
const hits = customCompletions.filter((c) => c.startsWith(line));
345342
// Show all completions if none found.
346343
callback(null, [hits.length ? hits : customCompletions, line]);
347344
}

0 commit comments

Comments
 (0)
Please sign in to comment.