@@ -6,11 +6,45 @@ import {
66 getPrereleaseChannel ,
77 getVersionGroupKey ,
88 getVersionGroupLabel ,
9+ isExactVersion ,
910 isSameVersionGroup ,
1011 parseVersion ,
1112 sortTags ,
1213} from '../../../../app/utils/versions'
1314
15+ describe ( 'isExactVersion' , ( ) => {
16+ it ( 'returns true for stable versions' , ( ) => {
17+ expect ( isExactVersion ( '1.0.0' ) ) . toBe ( true )
18+ expect ( isExactVersion ( '0.1.0' ) ) . toBe ( true )
19+ expect ( isExactVersion ( '10.20.30' ) ) . toBe ( true )
20+ } )
21+
22+ it ( 'returns true for prerelease versions' , ( ) => {
23+ expect ( isExactVersion ( '1.0.0-beta.1' ) ) . toBe ( true )
24+ expect ( isExactVersion ( '1.0.0-alpha.0' ) ) . toBe ( true )
25+ expect ( isExactVersion ( '5.8.0-rc' ) ) . toBe ( true )
26+ } )
27+
28+ it ( 'returns false for ranges' , ( ) => {
29+ expect ( isExactVersion ( '^1.0.0' ) ) . toBe ( false )
30+ expect ( isExactVersion ( '~1.0.0' ) ) . toBe ( false )
31+ expect ( isExactVersion ( '>=1.0.0' ) ) . toBe ( false )
32+ expect ( isExactVersion ( '1.0.x' ) ) . toBe ( false )
33+ expect ( isExactVersion ( '*' ) ) . toBe ( false )
34+ } )
35+
36+ it ( 'returns false for dist-tags' , ( ) => {
37+ expect ( isExactVersion ( 'latest' ) ) . toBe ( false )
38+ expect ( isExactVersion ( 'next' ) ) . toBe ( false )
39+ expect ( isExactVersion ( 'beta' ) ) . toBe ( false )
40+ } )
41+
42+ it ( 'returns false for invalid strings' , ( ) => {
43+ expect ( isExactVersion ( '' ) ) . toBe ( false )
44+ expect ( isExactVersion ( 'not-a-version' ) ) . toBe ( false )
45+ } )
46+ } )
47+
1448describe ( 'parseVersion' , ( ) => {
1549 it ( 'parses stable versions' , ( ) => {
1650 expect ( parseVersion ( '1.2.3' ) ) . toEqual ( {
0 commit comments