@@ -3,12 +3,6 @@ import {
33 calculateMismatchingVersions ,
44 filterOutIgnoredDependencies ,
55 fixMismatchingVersions ,
6- compareVersionRanges ,
7- compareVersionRangesSafe ,
8- compareRanges ,
9- versionRangeToRange ,
10- getLatestVersion ,
11- getHighestRangeType ,
126} from '../../lib/dependency-versions.js' ;
137import { getPackages } from '../../lib/workspace.js' ;
148import {
@@ -691,109 +685,4 @@ describe('Utils | dependency-versions', function () {
691685 } ) ;
692686 } ) ;
693687 } ) ;
694-
695- describe ( '#compareVersionRanges' , function ( ) {
696- it ( 'correctly chooses the higher range' , function ( ) {
697- // 1 (greater than)
698- expect ( compareVersionRanges ( '1.2.3' , '1.2.2' ) ) . toStrictEqual ( 1 ) ;
699- expect ( compareVersionRanges ( '5.0.0' , '4.0.0' ) ) . toStrictEqual ( 1 ) ;
700- expect ( compareVersionRanges ( '8.0.0-beta.1' , '^7' ) ) . toStrictEqual ( 1 ) ;
701- expect ( compareVersionRanges ( '^5.0.0' , '4.0.0' ) ) . toStrictEqual ( 1 ) ;
702- expect ( compareVersionRanges ( '^5.0.0' , '^4.0.0' ) ) . toStrictEqual ( 1 ) ;
703- expect ( compareVersionRanges ( '^5.0.0' , '~4.0.0' ) ) . toStrictEqual ( 1 ) ;
704- expect ( compareVersionRanges ( '^5.0.0' , '~5.0.0' ) ) . toStrictEqual ( 1 ) ;
705- expect ( compareVersionRanges ( '~5.0.0' , '5.0.0' ) ) . toStrictEqual ( 1 ) ;
706- expect ( compareVersionRanges ( '~5.0.0' , '~4.0.0' ) ) . toStrictEqual ( 1 ) ;
707-
708- // -1 (less than)
709- expect ( compareVersionRanges ( '4.0.0' , '5.0.0' ) ) . toStrictEqual ( - 1 ) ;
710- expect ( compareVersionRanges ( '5.0.0' , '~5.0.0' ) ) . toStrictEqual ( - 1 ) ;
711- expect ( compareVersionRanges ( '^4.0.0' , '^5.0.0' ) ) . toStrictEqual ( - 1 ) ;
712- expect ( compareVersionRanges ( '~4.0.0' , '~5.0.0' ) ) . toStrictEqual ( - 1 ) ;
713- expect ( compareVersionRanges ( '~5.0.0' , '^5.0.0' ) ) . toStrictEqual ( - 1 ) ;
714-
715- // 0 (equal)
716- expect ( compareVersionRanges ( '6' , '6' ) ) . toStrictEqual ( 0 ) ;
717- expect ( compareVersionRanges ( '6.0' , '6.0' ) ) . toStrictEqual ( 0 ) ;
718- expect ( compareVersionRanges ( '6.0.0' , '6.0.0' ) ) . toStrictEqual ( 0 ) ;
719- expect ( compareVersionRanges ( '^6.0.0' , '^6.0.0' ) ) . toStrictEqual ( 0 ) ;
720- expect ( compareVersionRanges ( 'v6' , '6' ) ) . toStrictEqual ( 0 ) ;
721- expect ( compareVersionRanges ( '~6.0.0' , '~6.0.0' ) ) . toStrictEqual ( 0 ) ;
722- } ) ;
723-
724- it ( 'throws with invalid ranges' , function ( ) {
725- expect ( ( ) =>
726- compareVersionRanges ( 'foo' , '~6.0.0' )
727- ) . toThrowErrorMatchingInlineSnapshot ( '"Invalid Version: foo"' ) ;
728- expect ( ( ) =>
729- compareVersionRanges ( '~6.0.0' , 'foo' )
730- ) . toThrowErrorMatchingInlineSnapshot ( '"Invalid Version: foo"' ) ;
731- } ) ;
732- } ) ;
733-
734- describe ( '#compareRanges' , function ( ) {
735- it ( 'behaves correctly' , function ( ) {
736- // gt
737- expect ( compareRanges ( '^' , '~' ) ) . toStrictEqual ( 1 ) ;
738- expect ( compareRanges ( '^' , '' ) ) . toStrictEqual ( 1 ) ;
739- expect ( compareRanges ( '~' , '' ) ) . toStrictEqual ( 1 ) ;
740-
741- // eq
742- expect ( compareRanges ( '' , '' ) ) . toStrictEqual ( 0 ) ;
743- expect ( compareRanges ( '~' , '~' ) ) . toStrictEqual ( 0 ) ;
744- expect ( compareRanges ( '^' , '^' ) ) . toStrictEqual ( 0 ) ;
745-
746- // lt
747- expect ( compareRanges ( '' , '~' ) ) . toStrictEqual ( - 1 ) ;
748- expect ( compareRanges ( '' , '^' ) ) . toStrictEqual ( - 1 ) ;
749- expect ( compareRanges ( '~' , '^' ) ) . toStrictEqual ( - 1 ) ;
750- } ) ;
751- } ) ;
752-
753- describe ( '#versionRangeToRange' , function ( ) {
754- it ( 'behaves correctly' , function ( ) {
755- expect ( versionRangeToRange ( '>1.0.0' ) ) . toStrictEqual ( '>' ) ;
756- expect ( versionRangeToRange ( '>=1.0.0' ) ) . toStrictEqual ( '>=' ) ;
757- expect ( versionRangeToRange ( '^1.0.0' ) ) . toStrictEqual ( '^' ) ;
758- expect ( versionRangeToRange ( '~1.0.0' ) ) . toStrictEqual ( '~' ) ;
759- expect ( versionRangeToRange ( '1.0.0' ) ) . toStrictEqual ( '' ) ;
760- } ) ;
761- } ) ;
762-
763- describe ( '#compareVersionRangesSafe' , function ( ) {
764- it ( 'behaves correctly' , function ( ) {
765- expect ( compareVersionRangesSafe ( '1.2.3' , '1.2.2' ) ) . toStrictEqual ( 1 ) ;
766- expect ( compareVersionRangesSafe ( '4.0.0' , '5.0.0' ) ) . toStrictEqual ( - 1 ) ;
767- expect ( compareVersionRangesSafe ( '6' , '6' ) ) . toStrictEqual ( 0 ) ;
768- } ) ;
769-
770- it ( 'does not throw with invalid ranges' , function ( ) {
771- expect ( compareVersionRangesSafe ( 'foo' , '~6.0.0' ) ) . toStrictEqual ( 0 ) ;
772- expect ( compareVersionRangesSafe ( '~6.0.0' , 'foo' ) ) . toStrictEqual ( 0 ) ;
773- } ) ;
774- } ) ;
775-
776- describe ( '#getLatestVersion' , function ( ) {
777- it ( 'correctly chooses the higher range' , function ( ) {
778- // Just basic sanity checks to ensure the data is passed through to `compareVersionRanges` which has extensive tests.
779- expect ( getLatestVersion ( [ '1.2.3' , '1.2.2' ] ) ) . toStrictEqual ( '1.2.3' ) ;
780- expect ( getLatestVersion ( [ '1.2.2' , '1.2.3' ] ) ) . toStrictEqual ( '1.2.3' ) ;
781- } ) ;
782-
783- it ( 'throws with invalid version' , function ( ) {
784- expect ( ( ) =>
785- getLatestVersion ( [ '1.2.3' , 'foo' ] )
786- ) . toThrowErrorMatchingInlineSnapshot ( '"Invalid Version: foo"' ) ;
787- } ) ;
788- } ) ;
789-
790- describe ( '#getHighestRangeType' , function ( ) {
791- it ( 'behaves correctly' , function ( ) {
792- expect ( getHighestRangeType ( [ '' , '' ] ) ) . toStrictEqual ( '' ) ;
793- expect ( getHighestRangeType ( [ '^' , '' ] ) ) . toStrictEqual ( '^' ) ;
794- expect ( getHighestRangeType ( [ '~' , '' ] ) ) . toStrictEqual ( '~' ) ;
795- expect ( getHighestRangeType ( [ '~' , '^' ] ) ) . toStrictEqual ( '^' ) ;
796- expect ( getHighestRangeType ( [ '^' , '~' ] ) ) . toStrictEqual ( '^' ) ;
797- } ) ;
798- } ) ;
799688} ) ;
0 commit comments