Skip to content

Commit

Permalink
test: publish: test add read registry only from publishConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-js authored and nlf committed Jan 28, 2021
1 parent 8d3fd63 commit f1bea2f
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/lib/publish.js
Expand Up @@ -369,3 +369,44 @@ t.test('throw if not logged in', async t => {
}, 'throws when not logged in')
})
})

t.test('read registry only from publishConfig', t => {
t.plan(3)

const publishConfig = { registry: 'https://some.registry' }
const testDir = t.testdir({
'package.json': JSON.stringify({
name: 'my-cool-pkg',
version: '1.0.0',
publishConfig,
}, null, 2),
})

const publish = requireInject('../../lib/publish.js', {
'../../lib/npm.js': {
flatOptions: {
json: false,
},
config,
},
'../../lib/utils/tar.js': {
getContents: () => ({
id: 'someid',
}),
logTar: () => {},
},
'../../lib/utils/output.js': () => {},
libnpmpublish: {
publish: (manifest, tarData, opts) => {
t.match(manifest, { name: 'my-cool-pkg', version: '1.0.0' }, 'gets manifest')
t.same(opts.registry, publishConfig.registry, 'publishConfig is passed through')
},
},
})

return publish([testDir], (er) => {
if (er)
throw er
t.pass('got to callback')
})
})

0 comments on commit f1bea2f

Please sign in to comment.