Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-02-23 02:59:21 +0300
committerGar <gar+gh@danger.computer>2021-02-25 21:23:43 +0300
commit113b1319f9e9c90694454bebc9dc12111a441ecf (patch)
tree7dd6bd1e39dd16889c2912f419307c029969b6d1 /test/lib/install.js
parent881a8558de5cb808c9efdcf3fb5d0a86a95e8eb0 (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/install.js')
-rw-r--r--test/lib/install.js74
1 files changed, 25 insertions, 49 deletions
diff --git a/test/lib/install.js b/test/lib/install.js
index 177952b9e..859a4bdaa 100644
--- a/test/lib/install.js
+++ b/test/lib/install.js
@@ -130,7 +130,7 @@ test('should install globally using Arborist', (t) => {
})
})
-test('completion to folder', (t) => {
+test('completion to folder', async t => {
const install = requireInject('../../lib/install.js', {
'../../lib/utils/reify-finish.js': async () => {},
util: {
@@ -145,17 +145,13 @@ test('completion to folder', (t) => {
},
},
})
- install.completion({
- partialWord: '/ar',
- }, (er, res) => {
- t.equal(er, null)
- const expect = process.platform === 'win32' ? '\\arborist' : '/arborist'
- t.strictSame(res, [expect], 'package dir match')
- t.end()
- })
+ const res = await install.completion({ partialWord: '/ar' })
+ const expect = process.platform === 'win32' ? '\\arborist' : '/arborist'
+ t.strictSame(res, [expect], 'package dir match')
+ t.end()
})
-test('completion to folder - invalid dir', (t) => {
+test('completion to folder - invalid dir', async t => {
const install = requireInject('../../lib/install.js', {
'../../lib/utils/reify-finish.js': async () => {},
util: {
@@ -167,16 +163,12 @@ test('completion to folder - invalid dir', (t) => {
},
},
})
- install.completion({
- partialWord: 'path/to/folder',
- }, (er, res) => {
- t.equal(er, null)
- t.strictSame(res, [], 'invalid dir: no matching')
- t.end()
- })
+ const res = await install.completion({ partialWord: 'path/to/folder' })
+ t.strictSame(res, [], 'invalid dir: no matching')
+ t.end()
})
-test('completion to folder - no matches', (t) => {
+test('completion to folder - no matches', async t => {
const install = requireInject('../../lib/install.js', {
'../../lib/utils/reify-finish.js': async () => {},
util: {
@@ -188,16 +180,12 @@ test('completion to folder - no matches', (t) => {
},
},
})
- install.completion({
- partialWord: '/pa',
- }, (er, res) => {
- t.equal(er, null)
- t.strictSame(res, [], 'no name match')
- t.end()
- })
+ const res = await install.completion({ partialWord: '/pa' })
+ t.strictSame(res, [], 'no name match')
+ t.end()
})
-test('completion to folder - match is not a package', (t) => {
+test('completion to folder - match is not a package', async t => {
const install = requireInject('../../lib/install.js', {
'../../lib/utils/reify-finish.js': async () => {},
util: {
@@ -212,31 +200,19 @@ test('completion to folder - match is not a package', (t) => {
},
},
})
- install.completion({
- partialWord: '/ar',
- }, (er, res) => {
- t.equal(er, null)
- t.strictSame(res, [], 'no name match')
- t.end()
- })
+ const res = await install.completion({ partialWord: '/ar' })
+ t.strictSame(res, [], 'no name match')
+ t.end()
})
-test('completion to url', (t) => {
- install.completion({
- partialWord: 'http://path/to/url',
- }, (er, res) => {
- t.equal(er, null)
- t.strictSame(res, [])
- t.end()
- })
+test('completion to url', async t => {
+ const res = await install.completion({ partialWord: 'http://path/to/url' })
+ t.strictSame(res, [])
+ t.end()
})
-test('completion', (t) => {
- install.completion({
- partialWord: 'toto',
- }, (er, res) => {
- t.notOk(er)
- t.notOk(res)
- t.end()
- })
+test('completion', async t => {
+ const res = await install.completion({ partialWord: 'toto' })
+ t.notOk(res)
+ t.end()
})