Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5ce2ac8

Browse filesBrowse files
TrottItalo A. Casas
authored andcommitted
test: refactor test-repl-tab-complete
* Add check for `data` object in tab completion callback * Replace `.indexOf()` with `.startsWith()` where appropriate PR-URL: #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>
1 parent 5d33c96 commit 5ce2ac8
Copy full SHA for 5ce2ac8

File tree

Expand file treeCollapse file tree

1 file changed

+3
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-6
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-repl-tab-complete.js
+3-6Lines changed: 3 additions & 6 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.