@@ -528,6 +528,61 @@ describe('node-support', () => {
528
528
await expect ( NodeSupport . detect ( { packageName : 'node-support' } ) )
529
529
. to . reject ( 'Something went wrong' ) ;
530
530
} ) ;
531
+
532
+ it ( 'throws when packument does not contain a `repository` field' , async ( ) => {
533
+
534
+ Nock ( 'https://registry.npmjs.org' )
535
+ . get ( '/node-support' )
536
+ . reply ( 200 , JSON . stringify ( { name : 'node-support' } ) ) ;
537
+
538
+ await expect ( NodeSupport . detect ( { packageName : 'node-support' } ) )
539
+ . to . reject ( 'Unable to determine the git repository for node-support' ) ;
540
+ } ) ;
541
+
542
+ it ( 'throws when packument does not contain a `repository.url` field' , async ( ) => {
543
+
544
+ Nock ( 'https://registry.npmjs.org' )
545
+ . get ( '/node-support' )
546
+ . reply ( 200 , JSON . stringify ( { name : 'node-support' , repository : { } } ) ) ;
547
+
548
+ await expect ( NodeSupport . detect ( { packageName : 'node-support' } ) )
549
+ . to . reject ( 'Unable to determine the git repository for node-support' ) ;
550
+ } ) ;
551
+
552
+ it ( 'returns node versions from `.travis.yml` in the package repository (string repository)' , async ( ) => {
553
+
554
+ listRemoteStub
555
+ . returns ( '9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n' ) ;
556
+
557
+ Nock ( 'https://raw.githubusercontent.com' )
558
+ . get ( '/pkgjs/node-support/HEAD/package.json' )
559
+ . reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) )
560
+ . get ( '/pkgjs/node-support/HEAD/.travis.yml' )
561
+ . reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , '.travis.yml' ) ) ) ;
562
+
563
+ Nock ( 'https://registry.npmjs.org' )
564
+ . get ( '/node-support' )
565
+ . reply ( 200 , JSON . stringify ( {
566
+ name : 'node-support' ,
567
+ repository : 'git+https://github.com/pkgjs/node-support.git'
568
+ } ) ) ;
569
+
570
+ const result = await NodeSupport . detect ( { packageName : 'node-support' } ) ;
571
+
572
+ expect ( listRemoteStub . callCount ) . to . equal ( 1 ) ;
573
+ expect ( listRemoteStub . args [ 0 ] ) . to . equal ( [ [ 'http://github.com/pkgjs/node-support.git' , 'HEAD' ] ] ) ;
574
+
575
+ expect ( result ) . to . equal ( {
576
+ name : 'node-support' ,
577
+ version : '0.0.0-development' ,
578
+ commit : '9cef39d21ad229dea4b10295f55b0d9a83800b23' ,
579
+ timestamp : 1580673602000 ,
580
+ travis : {
581
+ raw : [ '10' , '12' , '13' ]
582
+ } ,
583
+ engines : '>=10'
584
+ } ) ;
585
+ } ) ;
531
586
} ) ;
532
587
} ) ;
533
588
} ) ;
0 commit comments