@@ -500,6 +500,46 @@ describe('detect-node-support', () => {
500
500
} ) ;
501
501
} ) ;
502
502
503
+ it ( 'leaves out `travis` when no `.travis.yml` present' , async ( ) => {
504
+
505
+ listRemoteStub
506
+ . returns ( '9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n' ) ;
507
+
508
+ Nock ( 'https://raw.githubusercontent.com' )
509
+ . get ( '/pkgjs/detect-node-support/HEAD/package.json' )
510
+ . reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) )
511
+ . get ( '/pkgjs/detect-node-support/HEAD/.travis.yml' )
512
+ . reply ( 404 ) ;
513
+
514
+ const result = await NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/detect-node-support.git' } ) ;
515
+
516
+ expect ( listRemoteStub . callCount ) . to . equal ( 1 ) ;
517
+ expect ( listRemoteStub . args [ 0 ] ) . to . equal ( [ [ 'http://github.com/pkgjs/detect-node-support.git' , 'HEAD' ] ] ) ;
518
+
519
+ expect ( result ) . to . equal ( {
520
+ name : 'detect-node-support' ,
521
+ version : '0.0.0-development' ,
522
+ commit : '9cef39d21ad229dea4b10295f55b0d9a83800b23' ,
523
+ timestamp : 1580673602000 ,
524
+ engines : '>=10'
525
+ } ) ;
526
+ } ) ;
527
+
528
+ it ( 'throws when loading `.travis.yml` fails' , async ( ) => {
529
+
530
+ listRemoteStub
531
+ . returns ( '9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n' ) ;
532
+
533
+ Nock ( 'https://raw.githubusercontent.com' )
534
+ . get ( '/pkgjs/detect-node-support/HEAD/package.json' )
535
+ . reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) )
536
+ . get ( '/pkgjs/detect-node-support/HEAD/.travis.yml' )
537
+ . reply ( 500 ) ;
538
+
539
+ await expect ( NodeSupport . detect ( { repository : 'git+https://github.com/pkgjs/detect-node-support.git' } ) )
540
+ . to . reject ( 'Response Error: 500 null' ) ; // the null is a Nock/Wreck implementation detail
541
+ } ) ;
542
+
503
543
it ( 'throws when repository does not have a package.json' , async ( ) => {
504
544
505
545
listRemoteStub
@@ -583,6 +623,35 @@ describe('detect-node-support', () => {
583
623
} ) ;
584
624
} ) ;
585
625
626
+ it ( 'leaves out `travis` when no `.travis.yml` present' , async ( ) => {
627
+
628
+ listRemoteStub
629
+ . returns ( '9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n' ) ;
630
+
631
+ Nock ( 'https://raw.githubusercontent.com' )
632
+ . get ( '/pkgjs/detect-node-support/HEAD/package.json' )
633
+ . reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) )
634
+ . get ( '/pkgjs/detect-node-support/HEAD/.travis.yml' )
635
+ . reply ( 404 ) ;
636
+
637
+ Nock ( 'https://registry.npmjs.org' )
638
+ . get ( '/detect-node-support' )
639
+ . reply ( 200 , Fs . readFileSync ( Path . join ( __dirname , '..' , 'package.json' ) ) ) ;
640
+
641
+ const result = await NodeSupport . detect ( { packageName : 'detect-node-support' } ) ;
642
+
643
+ expect ( listRemoteStub . callCount ) . to . equal ( 1 ) ;
644
+ expect ( listRemoteStub . args [ 0 ] ) . to . equal ( [ [ 'http://github.com/pkgjs/detect-node-support.git' , 'HEAD' ] ] ) ;
645
+
646
+ expect ( result ) . to . equal ( {
647
+ name : 'detect-node-support' ,
648
+ version : '0.0.0-development' ,
649
+ commit : '9cef39d21ad229dea4b10295f55b0d9a83800b23' ,
650
+ timestamp : 1580673602000 ,
651
+ engines : '>=10'
652
+ } ) ;
653
+ } ) ;
654
+
586
655
it ( 'throws when package does not exist in the registry' , async ( ) => {
587
656
588
657
Nock ( 'https://registry.npmjs.org' )
0 commit comments