summaryrefslogtreecommitdiff
path: root/deps/npm/test/lib/owner.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/test/lib/owner.js')
-rw-r--r--deps/npm/test/lib/owner.js56
1 files changed, 27 insertions, 29 deletions
diff --git a/deps/npm/test/lib/owner.js b/deps/npm/test/lib/owner.js
index aa5e3ee637..4f8f430886 100644
--- a/deps/npm/test/lib/owner.js
+++ b/deps/npm/test/lib/owner.js
@@ -15,7 +15,6 @@ const mocks = {
npmlog,
'npm-registry-fetch': npmFetch,
pacote,
- '../../lib/npm.js': npm,
'../../lib/utils/output.js': (...msg) => {
result += msg.join('\n')
},
@@ -31,7 +30,8 @@ const npmcliMaintainers = [
{ email: 'i@izs.me', name: 'isaacs' },
]
-const owner = requireInject('../../lib/owner.js', mocks)
+const Owner = requireInject('../../lib/owner.js', mocks)
+const owner = new Owner(npm)
t.test('owner no args', t => {
result = ''
@@ -39,7 +39,7 @@ t.test('owner no args', t => {
result = ''
})
- owner([], err => {
+ owner.exec([], err => {
t.equal(
err.message,
'usage instructions',
@@ -73,7 +73,7 @@ t.test('owner ls no args', t => {
readLocalPkgResponse = null
})
- owner(['ls'], err => {
+ owner.exec(['ls'], err => {
t.ifError(err, 'npm owner ls no args')
t.matchSnapshot(result, 'should output owners of cwd package')
})
@@ -86,7 +86,7 @@ t.test('owner ls no args no cwd package', t => {
npmlog.error = noop
})
- owner(['ls'], err => {
+ owner.exec(['ls'], err => {
t.equal(
err.message,
'usage instructions',
@@ -115,7 +115,7 @@ t.test('owner ls fails to retrieve packument', t => {
pacote.packument = noop
})
- owner(['ls'], err => {
+ owner.exec(['ls'], err => {
t.match(
err,
/ERR/,
@@ -145,7 +145,7 @@ t.test('owner ls <pkg>', t => {
pacote.packument = noop
})
- owner(['ls', '@npmcli/map-workspaces'], err => {
+ owner.exec(['ls', '@npmcli/map-workspaces'], err => {
t.ifError(err, 'npm owner ls <pkg>')
t.matchSnapshot(result, 'should output owners of <pkg>')
})
@@ -161,7 +161,7 @@ t.test('owner ls <pkg> no maintainers', t => {
pacote.packument = noop
})
- owner(['ls', '@npmcli/map-workspaces'], err => {
+ owner.exec(['ls', '@npmcli/map-workspaces'], err => {
t.ifError(err, 'npm owner ls <pkg> no maintainers')
t.equal(result, 'no admin found', 'should output no admint found msg')
t.end()
@@ -232,7 +232,7 @@ t.test('owner add <user> <pkg>', t => {
pacote.packument = noop
})
- owner(['add', 'foo', '@npmcli/map-workspaces'], err => {
+ owner.exec(['add', 'foo', '@npmcli/map-workspaces'], err => {
t.ifError(err, 'npm owner add <user> <pkg>')
t.equal(result, '+ foo (@npmcli/map-workspaces)', 'should output add result')
})
@@ -265,7 +265,7 @@ t.test('owner add <user> cwd package', t => {
pacote.packument = noop
})
- owner(['add', 'foo'], err => {
+ owner.exec(['add', 'foo'], err => {
t.ifError(err, 'npm owner add <user> cwd package')
t.equal(result, '+ foo (@npmcli/map-workspaces)', 'should output add result')
t.end()
@@ -308,7 +308,7 @@ t.test('owner add <user> <pkg> already an owner', t => {
pacote.packument = noop
})
- owner(['add', 'ruyadorno', '@npmcli/map-workspaces'], err => {
+ owner.exec(['add', 'ruyadorno', '@npmcli/map-workspaces'], err => {
t.ifError(err, 'npm owner add <user> <pkg> already an owner')
})
})
@@ -336,7 +336,7 @@ t.test('owner add <user> <pkg> fails to retrieve user', t => {
pacote.packument = noop
})
- owner(['add', 'foo', '@npmcli/map-workspaces'], err => {
+ owner.exec(['add', 'foo', '@npmcli/map-workspaces'], err => {
t.match(
err,
/Error: Couldn't get user data for foo: {"ok":false}/,
@@ -377,7 +377,7 @@ t.test('owner add <user> <pkg> fails to PUT updates', t => {
pacote.packument = noop
})
- owner(['add', 'foo', '@npmcli/map-workspaces'], err => {
+ owner.exec(['add', 'foo', '@npmcli/map-workspaces'], err => {
t.match(
err.message,
/Failed to update package/,
@@ -417,7 +417,7 @@ t.test('owner add <user> <pkg> fails to retrieve user info', t => {
pacote.packument = noop
})
- owner(['add', 'foo', '@npmcli/map-workspaces'], err => {
+ owner.exec(['add', 'foo', '@npmcli/map-workspaces'], err => {
t.match(
err.message,
"I'm a teapot",
@@ -453,7 +453,7 @@ t.test('owner add <user> <pkg> no previous maintainers property from server', t
pacote.packument = noop
})
- owner(['add', 'foo', '@npmcli/no-owners-pkg'], err => {
+ owner.exec(['add', 'foo', '@npmcli/no-owners-pkg'], err => {
t.ifError(err, 'npm owner add <user> <pkg>')
t.equal(result, '+ foo (@npmcli/no-owners-pkg)', 'should output add result')
t.end()
@@ -466,7 +466,7 @@ t.test('owner add no user', t => {
result = ''
})
- owner(['add'], err => {
+ owner.exec(['add'], err => {
t.equal(
err.message,
'usage instructions',
@@ -482,7 +482,7 @@ t.test('owner add <user> no cwd package', t => {
result = ''
})
- owner(['add', 'foo'], err => {
+ owner.exec(['add', 'foo'], err => {
t.equal(
err.message,
'usage instructions',
@@ -549,7 +549,7 @@ t.test('owner rm <user> <pkg>', t => {
pacote.packument = noop
})
- owner(['rm', 'ruyadorno', '@npmcli/map-workspaces'], err => {
+ owner.exec(['rm', 'ruyadorno', '@npmcli/map-workspaces'], err => {
t.ifError(err, 'npm owner rm <user> <pkg>')
t.equal(result, '- ruyadorno (@npmcli/map-workspaces)', 'should output rm result')
})
@@ -589,7 +589,7 @@ t.test('owner rm <user> <pkg> not a current owner', t => {
pacote.packument = noop
})
- owner(['rm', 'foo', '@npmcli/map-workspaces'], err => {
+ owner.exec(['rm', 'foo', '@npmcli/map-workspaces'], err => {
t.ifError(err, 'npm owner rm <user> <pkg> not a current owner')
})
})
@@ -621,7 +621,7 @@ t.test('owner rm <user> cwd package', t => {
pacote.packument = noop
})
- owner(['rm', 'ruyadorno'], err => {
+ owner.exec(['rm', 'ruyadorno'], err => {
t.ifError(err, 'npm owner rm <user> cwd package')
t.equal(result, '- ruyadorno (@npmcli/map-workspaces)', 'should output rm result')
t.end()
@@ -656,7 +656,7 @@ t.test('owner rm <user> only user', t => {
pacote.packument = noop
})
- owner(['rm', 'ruyadorno'], err => {
+ owner.exec(['rm', 'ruyadorno'], err => {
t.equal(
err.message,
'Cannot remove all owners of a package. Add someone else first.',
@@ -673,7 +673,7 @@ t.test('owner rm no user', t => {
result = ''
})
- owner(['rm'], err => {
+ owner.exec(['rm'], err => {
t.equal(
err.message,
'usage instructions',
@@ -689,7 +689,7 @@ t.test('owner rm <user> no cwd package', t => {
result = ''
})
- owner(['rm', 'foo'], err => {
+ owner.exec(['rm', 'foo'], err => {
t.equal(
err.message,
'usage instructions',
@@ -700,10 +700,8 @@ t.test('owner rm <user> no cwd package', t => {
})
t.test('completion', async t => {
- const { completion } = owner
-
const testComp = async (argv, expect) => {
- const res = await completion({ conf: { argv: { remain: argv } } })
+ const res = await owner.completion({ conf: { argv: { remain: argv } } })
t.strictSame(res, expect, argv.join(' '))
}
@@ -730,7 +728,7 @@ t.test('completion', async t => {
pacote.packument = noop
})
- const res = await completion({ conf: { argv: { remain: ['npm', 'owner', 'rm'] } } })
+ const res = await owner.completion({ conf: { argv: { remain: ['npm', 'owner', 'rm'] } } })
t.strictSame(res,
['nlf', 'ruyadorno', 'darcyclarke', 'isaacs'],
'should return list of current owners'
@@ -738,7 +736,7 @@ t.test('completion', async t => {
})
t.test('completion npm owner rm no cwd package', async t => {
- const res = await completion({ conf: { argv: { remain: ['npm', 'owner', 'rm'] } } })
+ const res = await owner.completion({ conf: { argv: { remain: ['npm', 'owner', 'rm'] } } })
t.strictSame(res, [], 'should have no owners to autocomplete if not cwd package')
t.end()
})
@@ -757,7 +755,7 @@ t.test('completion', async t => {
pacote.packument = noop
})
- const res = await completion({ conf: { argv: { remain: ['npm', 'owner', 'rm'] } } })
+ const res = await owner.completion({ conf: { argv: { remain: ['npm', 'owner', 'rm'] } } })
t.strictSame(res, [], 'should return no owners if not found')
})