@@ -55,7 +55,7 @@ internals.assertCommit = (result) => {
55
55
delete result . commit ;
56
56
} ;
57
57
58
- describe ( 'node-support' , ( ) => {
58
+ describe ( 'detect- node-support' , ( ) => {
59
59
60
60
let listRemoteStub ;
61
61
@@ -79,6 +79,8 @@ describe('node-support', () => {
79
79
Nock . activate ( ) ;
80
80
}
81
81
82
+ Nock . disableNetConnect ( ) ;
83
+
82
84
Nock ( 'https://raw.githubusercontent.com' )
83
85
. persist ( )
84
86
. get ( '/nodejs/Release/master/schedule.json' )
@@ -103,6 +105,7 @@ describe('node-support', () => {
103
105
104
106
Nock . restore ( ) ;
105
107
Nock . cleanAll ( ) ;
108
+ Nock . enableNetConnect ( ) ;
106
109
} ) ;
107
110
108
111
describe ( 'detect()' , ( ) => {
@@ -118,7 +121,7 @@ describe('node-support', () => {
118
121
internals . assertCommit ( result ) ;
119
122
120
123
expect ( result ) . to . equal ( {
121
- name : 'node-support' ,
124
+ name : 'detect- node-support' ,
122
125
version : '0.0.0-development' ,
123
126
timestamp : 1580673602000 ,
124
127
travis : {
@@ -468,18 +471,18 @@ describe('node-support', () => {
468
471
. returns ( '9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n' ) ;
469
472
470
473
Nock ( 'https://raw.githubusercontent.com' )
471
- . get ( '/pkgjs/node-support/HEAD/package.json' )
474
+ . get ( '/pkgjs/detect- node-support/HEAD/package.json' )
472
475
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) )
473
- . get ( '/pkgjs/node-support/HEAD/.travis.yml' )
476
+ . get ( '/pkgjs/detect- node-support/HEAD/.travis.yml' )
474
477
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , '.travis.yml' ) ) ) ;
475
478
476
- const result = await NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/node-support.git' } ) ;
479
+ const result = await NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/detect- node-support.git' } ) ;
477
480
478
481
expect ( listRemoteStub . callCount ) . to . equal ( 1 ) ;
479
- expect ( listRemoteStub . args [ 0 ] ) . to . equal ( [ [ 'http://github.com/pkgjs/node-support.git' , 'HEAD' ] ] ) ;
482
+ expect ( listRemoteStub . args [ 0 ] ) . to . equal ( [ [ 'http://github.com/pkgjs/detect- node-support.git' , 'HEAD' ] ] ) ;
480
483
481
484
expect ( result ) . to . equal ( {
482
- name : 'node-support' ,
485
+ name : 'detect- node-support' ,
483
486
version : '0.0.0-development' ,
484
487
commit : '9cef39d21ad229dea4b10295f55b0d9a83800b23' ,
485
488
timestamp : 1580673602000 ,
@@ -501,24 +504,24 @@ describe('node-support', () => {
501
504
. returns ( '9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n' ) ;
502
505
503
506
Nock ( 'https://raw.githubusercontent.com' )
504
- . get ( '/pkgjs/node-support/HEAD/package.json' )
507
+ . get ( '/pkgjs/detect- node-support/HEAD/package.json' )
505
508
. reply ( 404 )
506
- . get ( '/pkgjs/node-support/HEAD/.travis.yml' )
509
+ . get ( '/pkgjs/detect- node-support/HEAD/.travis.yml' )
507
510
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , '.travis.yml' ) ) ) ;
508
511
509
- await expect ( NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/node-support.git' } ) )
510
- . to . reject ( `git+https://github.com/pkgjs/node-support.git does not contain a package.json` ) ;
512
+ await expect ( NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/detect- node-support.git' } ) )
513
+ . to . reject ( `git+https://github.com/pkgjs/detect- node-support.git does not contain a package.json` ) ;
511
514
} ) ;
512
515
513
516
it ( 'rethrows server errors' , async ( ) => {
514
517
515
518
Nock ( 'https://raw.githubusercontent.com' )
516
- . get ( '/pkgjs/node-support/HEAD/package.json' )
519
+ . get ( '/pkgjs/detect- node-support/HEAD/package.json' )
517
520
. reply ( 500 )
518
- . get ( '/pkgjs/node-support/HEAD/.travis.yml' )
521
+ . get ( '/pkgjs/detect- node-support/HEAD/.travis.yml' )
519
522
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , '.travis.yml' ) ) ) ;
520
523
521
- await expect ( NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/node-support.git' } ) )
524
+ await expect ( NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/detect- node-support.git' } ) )
522
525
. to . reject ( / R e s p o n s e E r r o r / ) ;
523
526
} ) ;
524
527
@@ -528,14 +531,14 @@ describe('node-support', () => {
528
531
529
532
Sinon . stub ( Wreck , 'get' ) . throws ( err ) ;
530
533
531
- await expect ( NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/node-support.git' } ) )
534
+ await expect ( NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/detect- node-support.git' } ) )
532
535
. to . reject ( 'Something went wrong' ) ;
533
536
} ) ;
534
537
535
538
it ( 'throws when a package does not live on public github.com' , async ( ) => {
536
539
537
- await expect ( NodeSupport . detect ( { repository : 'git+https://github.example.com/pkgjs/node-support.git' } ) )
538
- . to . reject ( 'Only github.com paths supported, feel free to PR at https://github.com/pkgjs/node-support' ) ;
540
+ await expect ( NodeSupport . detect ( { repository : 'git+https://github.example.com/pkgjs/detect- node-support.git' } ) )
541
+ . to . reject ( 'Only github.com paths supported, feel free to PR at https://github.com/pkgjs/detect- node-support' ) ;
539
542
} ) ;
540
543
} ) ;
541
544
@@ -547,22 +550,22 @@ describe('node-support', () => {
547
550
. returns ( '9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n' ) ;
548
551
549
552
Nock ( 'https://raw.githubusercontent.com' )
550
- . get ( '/pkgjs/node-support/HEAD/package.json' )
553
+ . get ( '/pkgjs/detect- node-support/HEAD/package.json' )
551
554
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) )
552
- . get ( '/pkgjs/node-support/HEAD/.travis.yml' )
555
+ . get ( '/pkgjs/detect- node-support/HEAD/.travis.yml' )
553
556
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , '.travis.yml' ) ) ) ;
554
557
555
558
Nock ( 'https://registry.npmjs.org' )
556
- . get ( '/node-support' )
559
+ . get ( '/detect- node-support' )
557
560
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) ) ;
558
561
559
- const result = await NodeSupport . detect ( { packageName : 'node-support' } ) ;
562
+ const result = await NodeSupport . detect ( { packageName : 'detect- node-support' } ) ;
560
563
561
564
expect ( listRemoteStub . callCount ) . to . equal ( 1 ) ;
562
- expect ( listRemoteStub . args [ 0 ] ) . to . equal ( [ [ 'http://github.com/pkgjs/node-support.git' , 'HEAD' ] ] ) ;
565
+ expect ( listRemoteStub . args [ 0 ] ) . to . equal ( [ [ 'http://github.com/pkgjs/detect- node-support.git' , 'HEAD' ] ] ) ;
563
566
564
567
expect ( result ) . to . equal ( {
565
- name : 'node-support' ,
568
+ name : 'detect- node-support' ,
566
569
version : '0.0.0-development' ,
567
570
commit : '9cef39d21ad229dea4b10295f55b0d9a83800b23' ,
568
571
timestamp : 1580673602000 ,
@@ -581,51 +584,55 @@ describe('node-support', () => {
581
584
it ( 'throws when package does not exist in the registry' , async ( ) => {
582
585
583
586
Nock ( 'https://registry.npmjs.org' )
584
- . get ( '/node-support' )
587
+ . get ( '/detect- node-support' )
585
588
. reply ( 404 ) ;
586
589
587
- await expect ( NodeSupport . detect ( { packageName : 'node-support' } ) )
588
- . to . reject ( `Package node-support does not exist` ) ;
590
+ await expect ( NodeSupport . detect ( { packageName : 'detect- node-support' } ) )
591
+ . to . reject ( `Package detect- node-support does not exist` ) ;
589
592
} ) ;
590
593
591
594
it ( 'rethrows registry server errors' , async ( ) => {
592
595
593
596
Nock ( 'https://registry.npmjs.org' )
594
- . get ( '/node-support' )
597
+ . get ( '/detect- node-support' )
595
598
. reply ( 500 ) ;
596
599
597
- await expect ( NodeSupport . detect ( { packageName : 'node-support' } ) )
600
+ await expect ( NodeSupport . detect ( { packageName : 'detect- node-support' } ) )
598
601
. to . reject ( / I n t e r n a l S e r v e r E r r o r / ) ;
599
602
} ) ;
600
603
601
604
it ( 'rethrows generic errors' , async ( ) => {
602
605
606
+ Nock ( 'https://registry.npmjs.org' )
607
+ . get ( '/detect-node-support' )
608
+ . reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) ) ;
609
+
603
610
const err = new Error ( 'Something went wrong' ) ;
604
611
605
612
Sinon . stub ( Wreck , 'get' ) . throws ( err ) ;
606
613
607
- await expect ( NodeSupport . detect ( { packageName : 'node-support' } ) )
614
+ await expect ( NodeSupport . detect ( { packageName : 'detect- node-support' } ) )
608
615
. to . reject ( 'Something went wrong' ) ;
609
616
} ) ;
610
617
611
618
it ( 'throws when packument does not contain a `repository` field' , async ( ) => {
612
619
613
620
Nock ( 'https://registry.npmjs.org' )
614
- . get ( '/node-support' )
615
- . reply ( 200 , JSON . stringify ( { name : 'node-support' } ) ) ;
621
+ . get ( '/detect- node-support' )
622
+ . reply ( 200 , JSON . stringify ( { name : 'detect- node-support' } ) ) ;
616
623
617
- await expect ( NodeSupport . detect ( { packageName : 'node-support' } ) )
618
- . to . reject ( 'Unable to determine the git repository for node-support' ) ;
624
+ await expect ( NodeSupport . detect ( { packageName : 'detect- node-support' } ) )
625
+ . to . reject ( 'Unable to determine the git repository for detect- node-support' ) ;
619
626
} ) ;
620
627
621
628
it ( 'throws when packument does not contain a `repository.url` field' , async ( ) => {
622
629
623
630
Nock ( 'https://registry.npmjs.org' )
624
- . get ( '/node-support' )
625
- . reply ( 200 , JSON . stringify ( { name : 'node-support' , repository : { } } ) ) ;
631
+ . get ( '/detect- node-support' )
632
+ . reply ( 200 , JSON . stringify ( { name : 'detect- node-support' , repository : { } } ) ) ;
626
633
627
- await expect ( NodeSupport . detect ( { packageName : 'node-support' } ) )
628
- . to . reject ( 'Unable to determine the git repository for node-support' ) ;
634
+ await expect ( NodeSupport . detect ( { packageName : 'detect- node-support' } ) )
635
+ . to . reject ( 'Unable to determine the git repository for detect- node-support' ) ;
629
636
} ) ;
630
637
631
638
it ( 'returns node versions from `.travis.yml` in the package repository (string repository)' , async ( ) => {
@@ -634,25 +641,25 @@ describe('node-support', () => {
634
641
. returns ( '9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n' ) ;
635
642
636
643
Nock ( 'https://raw.githubusercontent.com' )
637
- . get ( '/pkgjs/node-support/HEAD/package.json' )
644
+ . get ( '/pkgjs/detect- node-support/HEAD/package.json' )
638
645
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) )
639
- . get ( '/pkgjs/node-support/HEAD/.travis.yml' )
646
+ . get ( '/pkgjs/detect- node-support/HEAD/.travis.yml' )
640
647
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , '.travis.yml' ) ) ) ;
641
648
642
649
Nock ( 'https://registry.npmjs.org' )
643
- . get ( '/node-support' )
650
+ . get ( '/detect- node-support' )
644
651
. reply ( 200 , JSON . stringify ( {
645
- name : 'node-support' ,
646
- repository : 'git+https://github.com/pkgjs/node-support.git'
652
+ name : 'detect- node-support' ,
653
+ repository : 'git+https://github.com/pkgjs/detect- node-support.git'
647
654
} ) ) ;
648
655
649
- const result = await NodeSupport . detect ( { packageName : 'node-support' } ) ;
656
+ const result = await NodeSupport . detect ( { packageName : 'detect- node-support' } ) ;
650
657
651
658
expect ( listRemoteStub . callCount ) . to . equal ( 1 ) ;
652
- expect ( listRemoteStub . args [ 0 ] ) . to . equal ( [ [ 'http://github.com/pkgjs/node-support.git' , 'HEAD' ] ] ) ;
659
+ expect ( listRemoteStub . args [ 0 ] ) . to . equal ( [ [ 'http://github.com/pkgjs/detect- node-support.git' , 'HEAD' ] ] ) ;
653
660
654
661
expect ( result ) . to . equal ( {
655
- name : 'node-support' ,
662
+ name : 'detect- node-support' ,
656
663
version : '0.0.0-development' ,
657
664
commit : '9cef39d21ad229dea4b10295f55b0d9a83800b23' ,
658
665
timestamp : 1580673602000 ,
@@ -674,17 +681,17 @@ describe('node-support', () => {
674
681
. returns ( '9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n' ) ;
675
682
676
683
Nock ( 'https://raw.githubusercontent.com' )
677
- . get ( '/pkgjs/node-support/HEAD/package.json' )
684
+ . get ( '/pkgjs/detect- node-support/HEAD/package.json' )
678
685
. reply ( 200 , JSON . stringify ( { name : 'something-else' } ) )
679
- . get ( '/pkgjs/node-support/HEAD/.travis.yml' )
686
+ . get ( '/pkgjs/detect- node-support/HEAD/.travis.yml' )
680
687
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , '.travis.yml' ) ) ) ;
681
688
682
689
Nock ( 'https://registry.npmjs.org' )
683
- . get ( '/node-support' )
690
+ . get ( '/detect- node-support' )
684
691
. reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) ) ;
685
692
686
- await expect ( NodeSupport . detect ( { packageName : 'node-support' } ) )
687
- . to . reject ( 'git+https://github.com/pkgjs/node-support.git does not contain node-support' ) ;
693
+ await expect ( NodeSupport . detect ( { packageName : 'detect- node-support' } ) )
694
+ . to . reject ( 'git+https://github.com/pkgjs/detect- node-support.git does not contain detect- node-support' ) ;
688
695
} ) ;
689
696
} ) ;
690
697
} ) ;
0 commit comments