Repository: nodejs/node
Pull request: test: use mustSucceed in test-repl-tab-complete-import

Refactor test/parallel/test-repl-tab-complete-import.js to use mustSucceed instead of mustCall
in places where no error is expected in the callback. This clarifies the intent of the tests
and improves assertion accuracy.

- mustCall((err, data) => ...) -> mustSucceed((data) => ...)
- All affected callbacks are not expected to receive errors.
- Verified by running the full test suite.

Refs: https://github.com/nodejs/node/pull/59204

<!--
Before submitting a pull request, please read:

- the CONTRIBUTING guide at https://github.com/nodejs/node/blob/HEAD/CONTRIBUTING.md
- the commit message formatting guidelines at
  https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#commit-message-guidelines

For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that `make -j4 test` (UNIX), or `vcbuild test` (Windows) passes.

If you believe this PR should be highlighted in the Node.js CHANGELOG
please add the `notable-change` label.

Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->


Changed files:
filename: test/parallel/test-repl-tab-complete-import.js
patch: @@ -32,8 +32,7 @@ const testMe = repl.start({
 testMe._domain.on('error', assert.ifError);
 
 // Tab complete provides built in libs for import()
-testMe.complete('import(\'', common.mustCall((error, data) => {
-  assert.strictEqual(error, null);
+testMe.complete('import(\'', common.mustSucceed((data) => {
   publicUnprefixedModules.forEach((lib) => {
     assert(
       data[0].includes(lib) && data[0].includes(`node:${lib}`),
@@ -43,15 +42,14 @@ testMe.complete('import(\'', common.mustCall((error, data) => {
   const newModule = 'foobar';
   assert(!builtinModules.includes(newModule));
   repl.builtinModules.push(newModule);
-  testMe.complete('import(\'', common.mustCall((_, [modules]) => {
+  testMe.complete('import(\'', common.mustSucceed(([modules]) => {
     assert.strictEqual(data[0].length + 1, modules.length);
     assert(modules.includes(newModule) &&
       !modules.includes(`node:${newModule}`));
   }));
 }));
 
-testMe.complete("import\t( 'n", common.mustCall((error, data) => {
-  assert.strictEqual(error, null);
+testMe.complete("import\t( 'n", common.mustSucceed((data) => {
   assert.strictEqual(data.length, 2);
   assert.strictEqual(data[1], 'n');
   const completions = data[0];
@@ -77,16 +75,14 @@ testMe.complete("import\t( 'n", common.mustCall((error, data) => {
   // Import calls should handle all types of quotation marks.
   for (const quotationMark of ["'", '"', '`']) {
     putIn.run(['.clear']);
-    testMe.complete('import(`@nodejs', common.mustCall((err, data) => {
-      assert.strictEqual(err, null);
+    testMe.complete('import(`@nodejs', common.mustSucceed((data) => {
       assert.deepStrictEqual(data, [expected, '@nodejs']);
     }));
 
     putIn.run(['.clear']);
     // Completions should not be greedy in case the quotation ends.
     const input = `import(${quotationMark}@nodejsscope${quotationMark}`;
-    testMe.complete(input, common.mustCall((err, data) => {
-      assert.strictEqual(err, null);
+    testMe.complete(input, common.mustSucceed((data) => {
       assert.deepStrictEqual(data, [[], undefined]);
     }));
   }
@@ -96,8 +92,7 @@ testMe.complete("import\t( 'n", common.mustCall((error, data) => {
   putIn.run(['.clear']);
   // Completions should find modules and handle whitespace after the opening
   // bracket.
-  testMe.complete('import \t("no_ind', common.mustCall((err, data) => {
-    assert.strictEqual(err, null);
+  testMe.complete('import \t("no_ind', common.mustSucceed((data) => {
     assert.deepStrictEqual(data, [['no_index', 'no_index/'], 'no_ind']);
   }));
 }
@@ -110,8 +105,7 @@ testMe.complete("import\t( 'n", common.mustCall((error, data) => {
   process.chdir(__dirname);
 
   ['import(\'.', 'import(".'].forEach((input) => {
-    testMe.complete(input, common.mustCall((err, data) => {
-      assert.strictEqual(err, null);
+    testMe.complete(input, common.mustSucceed((data) => {
       assert.strictEqual(data.length, 2);
       assert.strictEqual(data[1], '.');
       assert.strictEqual(data[0].length, 2);
@@ -121,16 +115,14 @@ testMe.complete("import\t( 'n", common.mustCall((error, data) => {
   });
 
   ['import(\'..', 'import("..'].forEach((input) => {
-    testMe.complete(input, common.mustCall((err, data) => {
-      assert.strictEqual(err, null);
+    testMe.complete(input, common.mustSucceed((data) => {
       assert.deepStrictEqual(data, [['../'], '..']);
     }));
   });
 
   ['./', './test-'].forEach((path) => {
     [`import('${path}`, `import("${path}`].forEach((input) => {
-      testMe.complete(input, common.mustCall((err, data) => {
-        assert.strictEqual(err, null);
+      testMe.complete(input, common.mustSucceed((data) => {
         assert.strictEqual(data.length, 2);
         assert.strictEqual(data[1], path);
         assert.ok(data[0].includes('./test-repl-tab-complete.js'));
@@ -140,8 +132,7 @@ testMe.complete("import\t( 'n", common.mustCall((error, data) => {
 
   ['../parallel/', '../parallel/test-'].forEach((path) => {
     [`import('${path}`, `import("${path}`].forEach((input) => {
-      testMe.complete(input, common.mustCall((err, data) => {
-        assert.strictEqual(err, null);
+      testMe.complete(input, common.mustSucceed((data) => {
         assert.strictEqual(data.length, 2);
         assert.strictEqual(data[1], path);
         assert.ok(data[0].includes('../parallel/test-repl-tab-complete.js'));