@@ -477,4 +477,107 @@ describe('dependency-audit Unit Tests', function() {
477477 } ) ;
478478 } ) ;
479479 } ) ;
480+
481+ describe ( 'isVersionAbsolute method' , function ( ) {
482+ context ( 'when the node does not exist in the package.json file' , function ( ) {
483+ it ( 'true should be returned' , function ( ) {
484+ const packageJson = {
485+ dependencies : {
486+ 'npm-package-json-lint' : '^1.0.0' ,
487+ 'grunt-npm-package-json-lint' : '~2.0.0-beta1' ,
488+ 'gulp-npm-package-json-lint' : '^2.0.0-rc1'
489+ }
490+ } ;
491+ const response = dependencyAudit . isVersionAbsolute ( packageJson , 'devDependencies' ) ;
492+
493+ response . should . be . true ( ) ;
494+ } ) ;
495+ } ) ;
496+
497+ context ( 'when the node exists in the package.json file, not all versions are absolute' , function ( ) {
498+ it ( 'with caret versioning false should be returned' , function ( ) {
499+ const packageJson = {
500+ dependencies : {
501+ 'npm-package-json-lint' : '^1.0.0' ,
502+ 'gulp-npm-package-json-lint' : '^2.0.0-rc1'
503+ }
504+ } ;
505+ const response = dependencyAudit . isVersionAbsolute ( packageJson , 'dependencies' ) ;
506+
507+ response . should . be . false ( ) ;
508+ } ) ;
509+ it ( 'with tilde versioning false should be returned' , function ( ) {
510+ const packageJson = {
511+ dependencies : {
512+ 'npm-package-json-lint' : '~1.0.0' ,
513+ 'gulp-npm-package-json-lint' : '~2.0.0-rc1'
514+ }
515+ } ;
516+ const response = dependencyAudit . isVersionAbsolute ( packageJson , 'dependencies' ) ;
517+
518+ response . should . be . false ( ) ;
519+ } ) ;
520+ it ( 'with star versioning false should be returned' , function ( ) {
521+ const packageJson = {
522+ dependencies : {
523+ 'npm-package-json-lint' : '1.0.*' ,
524+ 'gulp-npm-package-json-lint' : '2.*'
525+ }
526+ } ;
527+ const response = dependencyAudit . isVersionAbsolute ( packageJson , 'dependencies' ) ;
528+
529+ response . should . be . false ( ) ;
530+ } ) ;
531+ it ( 'with greater versioning false should be returned' , function ( ) {
532+ const packageJson = {
533+ dependencies : {
534+ 'npm-package-json-lint' : '>1.0.0' ,
535+ 'gulp-npm-package-json-lint' : '>=2.0.0'
536+ }
537+ } ;
538+ const response = dependencyAudit . isVersionAbsolute ( packageJson , 'dependencies' ) ;
539+
540+ response . should . be . false ( ) ;
541+ } ) ;
542+ it ( 'with greater versioning false should be returned' , function ( ) {
543+ const packageJson = {
544+ dependencies : {
545+ 'npm-package-json-lint' : '>1.0.0' ,
546+ 'gulp-npm-package-json-lint' : '>=2.0.0'
547+ }
548+ } ;
549+ const response = dependencyAudit . isVersionAbsolute ( packageJson , 'dependencies' ) ;
550+
551+ response . should . be . false ( ) ;
552+ } ) ;
553+ it ( 'with less versioning false should be returned' , function ( ) {
554+ const packageJson = {
555+ dependencies : {
556+ 'npm-package-json-lint' : '<1.0.0' ,
557+ 'gulp-npm-package-json-lint' : '<=2.0.0'
558+ }
559+ } ;
560+ const response = dependencyAudit . isVersionAbsolute ( packageJson , 'dependencies' ) ;
561+
562+ response . should . be . false ( ) ;
563+ } ) ;
564+ } ) ;
565+
566+ context ( 'when the node exists in the package.json file, all versions are absolute' , function ( ) {
567+ it ( 'true should be returned' , function ( ) {
568+ const packageJson = {
569+ dependencies : {
570+ 'npm-package-json-lint' : '1.0.0' ,
571+ 'grunt-npm-package-json-lint' : '2.1.0' ,
572+ 'gulp-npm-package-json-lint' : '=2.4.0'
573+ }
574+ } ;
575+ const response = dependencyAudit . isVersionAbsolute ( packageJson , 'dependencies' ) ;
576+
577+ response . should . be . true ( ) ;
578+ } ) ;
579+ } ) ;
580+
581+ } ) ;
582+
480583} ) ;
0 commit comments