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/deprecate.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/deprecate.js')
-rw-r--r-- | test/lib/deprecate.js | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/test/lib/deprecate.js b/test/lib/deprecate.js index 229cb9137..fd563de12 100644 --- a/test/lib/deprecate.js +++ b/test/lib/deprecate.js @@ -38,29 +38,24 @@ test('completion', async t => { const { completion } = deprecate - const testComp = (argv, expect) => { - return new Promise((resolve, reject) => { - completion({ conf: { argv: { remain: argv } } }, (err, res) => { - if (err) - return reject(err) - - t.strictSame(res, expect, `completion: ${argv}`) - resolve() - }) - }) + const testComp = async (argv, expect) => { + const res = await completion({ conf: { argv: { remain: argv } } }) + t.strictSame(res, expect, `completion: ${argv}`) } - await testComp([], ['foo', 'bar', 'baz']) - await testComp(['b'], ['bar', 'baz']) - await testComp(['fo'], ['foo']) - await testComp(['g'], []) - await testComp(['foo', 'something'], []) + await Promise.all([ + testComp([], ['foo', 'bar', 'baz']), + testComp(['b'], ['bar', 'baz']), + testComp(['fo'], ['foo']), + testComp(['g'], []), + testComp(['foo', 'something'], []), + ]) getIdentityImpl = () => { - throw new Error('unknown failure') + throw new Error('deprecate test failure') } - t.rejects(testComp([], []), /unknown failure/) + t.rejects(testComp([], []), { message: 'deprecate test failure' }) }) test('no args', t => { |