diff --git a/test/lib/commands/publish.js b/test/lib/commands/publish.js index e266ea524ccc0..64eb7c60cb062 100644 --- a/test/lib/commands/publish.js +++ b/test/lib/commands/publish.js @@ -227,6 +227,18 @@ t.test( ), }) + const npm = mockNpm({ + config: { 'dry-run': true, loglevel: 'info' }, + output: () => { + t.pass('output fn is called') + }, + }, t) + const registry = npm.config.get('registry') + npm.config.getCredentialsByURI = uri => { + t.same(uri, registry, 'gets credentials for expected registry') + return { /* no token will call log.warn */ } + } + const Publish = t.mock('../../../lib/commands/publish.js', { '../../../lib/utils/tar.js': { getContents: () => ({ @@ -235,6 +247,12 @@ t.test( logTar: () => { t.pass('logTar is called') }, + 'proc-log': { + warn (_, msg) { + t.match(msg, + `This command requires you to be logged in to ${registry} (dry-run)`) + }, + }, }, libnpmpublish: { publish: () => { @@ -242,16 +260,6 @@ t.test( }, }, }) - const npm = mockNpm({ - config: { 'dry-run': true, loglevel: 'info' }, - output: () => { - t.pass('output fn is called') - }, - }, t) - npm.config.getCredentialsByURI = uri => { - t.same(uri, npm.config.get('registry'), 'gets credentials for expected registry') - return { token: 'some.registry.token' } - } const publish = new Publish(npm)