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