@@ -3,13 +3,24 @@ import { getNewest, getVersionRange, sortBySemver } from './version';
33
44describe ( 'getNewest' , ( ) => {
55 it ( 'returns the newest version from an array of versions' , ( ) => {
6- expect ( getNewest ( [ '<=1.0.0' , '<1.0.0' ] ) ) . toEqual ( '<=1.0.0' ) ;
7- expect ( getNewest ( [ '1.0.0' , '<=1.0.0' , '<1.0.0' ] ) ) . toEqual ( '1.0.0' ) ;
8- expect ( getNewest ( [ '~1.0.0' , '1.0.0' , '<=1.0.0' , '<1.0.0' ] ) ) . toEqual ( '~1.0.0' ) ;
9- expect ( getNewest ( [ '^1.0.0' , '~1.0.0' , '1.0.0' , '<=1.0.0' , '<1.0.0' ] ) ) . toEqual ( '^1.0.0' ) ;
10- expect ( getNewest ( [ '>=1.0.0' , '^1.0.0' , '~1.0.0' , '1.0.0' , '<=1.0.0' , '<1.0.0' ] ) ) . toEqual ( '>=1.0.0' ) ;
11- expect ( getNewest ( [ '>1.0.0' , '>=1.0.0' , '^1.0.0' , '~1.0.0' , '1.0.0' , '<=1.0.0' , '<1.0.0' ] ) ) . toEqual ( '>1.0.0' ) ;
12- expect ( getNewest ( [ '>1.0.0' , '>=1.0.0' , '^1.0.0' , '*' , '~1.0.0' , '1.0.0' , '<=1.0.0' , '<1.0.0' ] ) ) . toEqual ( '*' ) ;
6+ const a = [ '<1.0.0' ] ;
7+ const b = _ . shuffle ( a . concat ( '<=1.0.0' ) ) ;
8+ const c = _ . shuffle ( b . concat ( '1.0.0' ) ) ;
9+ const d = _ . shuffle ( c . concat ( '~1.0.0' ) ) ;
10+ const e = _ . shuffle ( d . concat ( '1.x.x' ) ) ;
11+ const f = _ . shuffle ( e . concat ( '^1.0.0' ) ) ;
12+ const g = _ . shuffle ( f . concat ( '>=1.0.0' ) ) ;
13+ const h = _ . shuffle ( g . concat ( '>1.0.0' ) ) ;
14+ const i = _ . shuffle ( h . concat ( '*' ) ) ;
15+ expect ( getNewest ( a ) ) . toEqual ( '<1.0.0' ) ;
16+ expect ( getNewest ( b ) ) . toEqual ( '<=1.0.0' ) ;
17+ expect ( getNewest ( c ) ) . toEqual ( '1.0.0' ) ;
18+ expect ( getNewest ( d ) ) . toEqual ( '~1.0.0' ) ;
19+ expect ( getNewest ( e ) ) . toEqual ( '1.x.x' ) ;
20+ expect ( getNewest ( f ) ) . toEqual ( '^1.0.0' ) ;
21+ expect ( getNewest ( g ) ) . toEqual ( '>=1.0.0' ) ;
22+ expect ( getNewest ( h ) ) . toEqual ( '>1.0.0' ) ;
23+ expect ( getNewest ( i ) ) . toEqual ( '*' ) ;
1324 } ) ;
1425} ) ;
1526
0 commit comments