diff options
Diffstat (limited to 'deps/npm/test/lib/utils/completion')
-rw-r--r-- | deps/npm/test/lib/utils/completion/installed-deep.js | 125 | ||||
-rw-r--r-- | deps/npm/test/lib/utils/completion/installed-shallow.js | 49 | ||||
-rw-r--r-- | deps/npm/test/lib/utils/completion/none.js | 6 |
3 files changed, 79 insertions, 101 deletions
diff --git a/deps/npm/test/lib/utils/completion/installed-deep.js b/deps/npm/test/lib/utils/completion/installed-deep.js index a2a3756104f..bd61ab42809 100644 --- a/deps/npm/test/lib/utils/completion/installed-deep.js +++ b/deps/npm/test/lib/utils/completion/installed-deep.js @@ -11,7 +11,8 @@ const _flatOptions = { return prefix }, } -const installedDeep = requireInject('../../../../lib/utils/completion/installed-deep.js', { +const p = '../../../../lib/utils/completion/installed-deep.js' +const installedDeep = requireInject(p, { '../../../../lib/npm.js': { flatOptions: _flatOptions, get prefix () { @@ -144,7 +145,7 @@ const globalFixture = { }, } -test('get list of package names', (t) => { +test('get list of package names', async t => { const fix = t.testdir({ local: fixture, global: globalFixture, @@ -153,25 +154,23 @@ test('get list of package names', (t) => { prefix = resolve(fix, 'local') globalDir = resolve(fix, 'global/node_modules') - installedDeep(null, (err, res) => { - t.ifError(err, 'should not error out') - t.deepEqual( - res, - [ - ['bar', '-g'], - ['foo', '-g'], - ['a-bar', '-g'], - 'a', 'b', 'c', - 'd', 'e', 'f', - 'g', 'bb', - ], - 'should return list of package names and global flag' - ) - t.end() - }) + const res = await installedDeep(null) + t.deepEqual( + res, + [ + ['bar', '-g'], + ['foo', '-g'], + ['a-bar', '-g'], + 'a', 'b', 'c', + 'd', 'e', 'f', + 'g', 'bb', + ], + 'should return list of package names and global flag' + ) + t.end() }) -test('get list of package names as global', (t) => { +test('get list of package names as global', async t => { const fix = t.testdir({ local: fixture, global: globalFixture, @@ -182,23 +181,21 @@ test('get list of package names as global', (t) => { _flatOptions.global = true - installedDeep(null, (err, res) => { - t.ifError(err, 'should not error out') - t.deepEqual( - res, - [ - 'bar', - 'foo', - 'a-bar', - ], - 'should return list of global packages with no extra flags' - ) - _flatOptions.global = false - t.end() - }) + const res = await installedDeep(null) + t.deepEqual( + res, + [ + 'bar', + 'foo', + 'a-bar', + ], + 'should return list of global packages with no extra flags' + ) + _flatOptions.global = false + t.end() }) -test('limit depth', (t) => { +test('limit depth', async t => { const fix = t.testdir({ local: fixture, global: globalFixture, @@ -209,26 +206,24 @@ test('limit depth', (t) => { _flatOptions.depth = 0 - installedDeep(null, (err, res) => { - t.ifError(err, 'should not error out') - t.deepEqual( - res, - [ - ['bar', '-g'], - ['foo', '-g'], - 'a', 'b', - 'c', 'd', - 'e', 'f', - 'g', - ], - 'should print only packages up to the specified depth' - ) - _flatOptions.depth = 0 - t.end() - }) + const res = await installedDeep(null) + t.deepEqual( + res, + [ + ['bar', '-g'], + ['foo', '-g'], + 'a', 'b', + 'c', 'd', + 'e', 'f', + 'g', + ], + 'should print only packages up to the specified depth' + ) + _flatOptions.depth = 0 + t.end() }) -test('limit depth as global', (t) => { +test('limit depth as global', async t => { const fix = t.testdir({ local: fixture, global: globalFixture, @@ -240,18 +235,16 @@ test('limit depth as global', (t) => { _flatOptions.global = true _flatOptions.depth = 0 - installedDeep(null, (err, res) => { - t.ifError(err, 'should not error out') - t.deepEqual( - res, - [ - 'bar', - 'foo', - ], - 'should reorder so that packages above that level depth goes last' - ) - _flatOptions.global = false - _flatOptions.depth = 0 - t.end() - }) + const res = await installedDeep(null) + t.deepEqual( + res, + [ + 'bar', + 'foo', + ], + 'should reorder so that packages above that level depth goes last' + ) + _flatOptions.global = false + _flatOptions.depth = 0 + t.end() }) diff --git a/deps/npm/test/lib/utils/completion/installed-shallow.js b/deps/npm/test/lib/utils/completion/installed-shallow.js index 1d6369bc782..1da68810b54 100644 --- a/deps/npm/test/lib/utils/completion/installed-shallow.js +++ b/deps/npm/test/lib/utils/completion/installed-shallow.js @@ -9,7 +9,7 @@ const installed = requireInject(p, { '../../../../lib/npm.js': npm, }) -t.test('global not set, include globals with -g', t => { +t.test('global not set, include globals with -g', async t => { const dir = t.testdir({ global: { node_modules: { @@ -32,21 +32,17 @@ t.test('global not set, include globals with -g', t => { npm.localDir = resolve(dir, 'local/node_modules') flatOptions.global = false const opt = { conf: { argv: { remain: [] } } } - installed(opt, (er, res) => { - if (er) - throw er - - t.strictSame(res.sort(), [ - '@scope/y -g', - 'x -g', - 'a', - '@scope/b', - ].sort()) - t.end() - }) + const res = await installed(opt) + t.strictSame(res.sort(), [ + '@scope/y -g', + 'x -g', + 'a', + '@scope/b', + ].sort()) + t.end() }) -t.test('global set, include globals and not locals', t => { +t.test('global set, include globals and not locals', async t => { const dir = t.testdir({ global: { node_modules: { @@ -69,16 +65,15 @@ t.test('global set, include globals and not locals', t => { npm.localDir = resolve(dir, 'local/node_modules') flatOptions.global = true const opt = { conf: { argv: { remain: [] } } } - installed(opt, (er, res) => { - t.strictSame(res.sort(), [ - '@scope/y', - 'x', - ].sort()) - t.end() - }) + const res = await installed(opt) + t.strictSame(res.sort(), [ + '@scope/y', + 'x', + ].sort()) + t.end() }) -t.test('more than 3 items in argv, skip it', t => { +t.test('more than 3 items in argv, skip it', async t => { const dir = t.testdir({ global: { node_modules: { @@ -101,11 +96,7 @@ t.test('more than 3 items in argv, skip it', t => { npm.localDir = resolve(dir, 'local/node_modules') flatOptions.global = false const opt = { conf: { argv: { remain: [1, 2, 3, 4, 5, 6] } } } - installed(opt, (er, res) => { - if (er) - throw er - - t.strictSame(res, null) - t.end() - }) + const res = await installed(opt) + t.strictSame(res, null) + t.end() }) diff --git a/deps/npm/test/lib/utils/completion/none.js b/deps/npm/test/lib/utils/completion/none.js deleted file mode 100644 index 70488be07ec..00000000000 --- a/deps/npm/test/lib/utils/completion/none.js +++ /dev/null @@ -1,6 +0,0 @@ -const t = require('tap') -const none = require('../../../../lib/utils/completion/none.js') -none({any: 'thing'}, (er, res) => { - t.equal(er, null) - t.strictSame(res, []) -}) |