diff options
author | Gar <gar+gh@danger.computer> | 2021-02-23 02:59:21 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-02-25 21:23:43 +0300 |
commit | 113b1319f9e9c90694454bebc9dc12111a441ecf (patch) | |
tree | 7dd6bd1e39dd16889c2912f419307c029969b6d1 /test/lib/help.js | |
parent | 881a8558de5cb808c9efdcf3fb5d0a86a95e8eb0 (diff) |
chore(refactor): promisify completion scripts
We also removed the "none" script because we handle a missing
script just fine. There is no need to put an empty one in
PR-URL: https://github.com/npm/cli/pull/2759
Credit: @wraithgar
Close: #2759
Reviewed-by: @nlf
Diffstat (limited to 'test/lib/help.js')
-rw-r--r-- | test/lib/help.js | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/test/lib/help.js b/test/lib/help.js index 40a035421..fc4a32e07 100644 --- a/test/lib/help.js +++ b/test/lib/help.js @@ -101,20 +101,13 @@ test('npm help completion', async t => { t.teardown(() => { globErr = null }) - const completion = (opts) => new Promise((resolve, reject) => { - help.completion(opts, (err, res) => { - if (err) - return reject(err) - return resolve(res) - }) - }) - const noArgs = await completion({ conf: { argv: { remain: [] } } }) + const noArgs = await help.completion({ conf: { argv: { remain: [] } } }) t.strictSame(noArgs, ['help', 'whoami', 'npmrc', 'disputes'], 'outputs available help pages') - const threeArgs = await completion({ conf: { argv: { remain: ['one', 'two', 'three'] } } }) + const threeArgs = await help.completion({ conf: { argv: { remain: ['one', 'two', 'three'] } } }) t.strictSame(threeArgs, [], 'outputs no results when more than 2 args are provided') globErr = new Error('glob failed') - t.rejects(completion({ conf: { argv: { remain: [] } } }), /glob failed/, 'glob errors propagate') + t.rejects(help.completion({ conf: { argv: { remain: [] } } }), /glob failed/, 'glob errors propagate') }) test('npm help -h', t => { |