@@ -341,8 +341,10 @@ t.test('can publish a tarball', async t => {
341
341
342
342
t . test ( 'should check auth for default registry' , async t => {
343
343
t . plan ( 2 )
344
- const Publish = t . mock ( '../../../lib/commands/publish.js' )
345
344
const npm = mockNpm ( )
345
+ const registry = npm . config . get ( 'registry' )
346
+ const errorMessage = `This command requires you to be logged in to ${ registry } `
347
+ const Publish = t . mock ( '../../../lib/commands/publish.js' )
346
348
npm . config . getCredentialsByURI = uri => {
347
349
t . same ( uri , npm . config . get ( 'registry' ) , 'gets credentials for expected registry' )
348
350
return { }
@@ -351,14 +353,15 @@ t.test('should check auth for default registry', async t => {
351
353
352
354
await t . rejects (
353
355
publish . exec ( [ ] ) ,
354
- { message : 'This command requires you to be logged in.' , code : 'ENEEDAUTH' } ,
356
+ { message : errorMessage , code : 'ENEEDAUTH' } ,
355
357
'throws when not logged in'
356
358
)
357
359
} )
358
360
359
361
t . test ( 'should check auth for configured registry' , async t => {
360
362
t . plan ( 2 )
361
363
const registry = 'https://some.registry'
364
+ const errorMessage = 'This command requires you to be logged in to https://some.registry'
362
365
const Publish = t . mock ( '../../../lib/commands/publish.js' )
363
366
const npm = mockNpm ( {
364
367
flatOptions : { registry } ,
@@ -371,14 +374,15 @@ t.test('should check auth for configured registry', async t => {
371
374
372
375
await t . rejects (
373
376
publish . exec ( [ ] ) ,
374
- { message : 'This command requires you to be logged in.' , code : 'ENEEDAUTH' } ,
377
+ { message : errorMessage , code : 'ENEEDAUTH' } ,
375
378
'throws when not logged in'
376
379
)
377
380
} )
378
381
379
382
t . test ( 'should check auth for scope specific registry' , async t => {
380
383
t . plan ( 2 )
381
384
const registry = 'https://some.registry'
385
+ const errorMessage = 'This command requires you to be logged in to https://some.registry'
382
386
const testDir = t . testdir ( {
383
387
'package.json' : JSON . stringify (
384
388
{
@@ -402,7 +406,7 @@ t.test('should check auth for scope specific registry', async t => {
402
406
403
407
await t . rejects (
404
408
publish . exec ( [ testDir ] ) ,
405
- { message : 'This command requires you to be logged in.' , code : 'ENEEDAUTH' } ,
409
+ { message : errorMessage , code : 'ENEEDAUTH' } ,
406
410
'throws when not logged in'
407
411
)
408
412
} )
@@ -735,7 +739,7 @@ t.test('private workspaces', async t => {
735
739
} )
736
740
737
741
t . test ( 'unexpected error' , async t => {
738
- t . plan ( 1 )
742
+ t . plan ( 2 )
739
743
740
744
const Publish = t . mock ( '../../../lib/commands/publish.js' , {
741
745
...mocks ,
@@ -749,7 +753,9 @@ t.test('private workspaces', async t => {
749
753
} ,
750
754
} ,
751
755
'proc-log' : {
752
- notice ( ) { } ,
756
+ notice ( __ , msg ) {
757
+ t . match ( msg , 'Publishing to https://registry.npmjs.org/' )
758
+ } ,
753
759
verbose ( ) { } ,
754
760
} ,
755
761
} )
0 commit comments