@@ -17,7 +17,7 @@ import {
1717 PARALLELISM_LIMITS ,
1818 DEFAULT_CONFIG ,
1919} from '../../src/core/types.js' ;
20- import { VERSION } from '../../src/core/version.js' ;
20+ import { VERSION , parseVersion , isVersionAtLeast , getVersion } from '../../src/core/version.js' ;
2121
2222describe ( 'CmdResult' , ( ) => {
2323 it ( 'cmdOk creates a successful result with data' , ( ) => {
@@ -148,6 +148,49 @@ describe('VERSION', () => {
148148 } ) ;
149149} ) ;
150150
151+ describe ( 'parseVersion' , ( ) => {
152+ it ( 'parses a valid semver string' , ( ) => {
153+ expect ( parseVersion ( '1.2.3' ) ) . toEqual ( { major : 1 , minor : 2 , patch : 3 } ) ;
154+ } ) ;
155+
156+ it ( 'parses semver with pre-release suffix' , ( ) => {
157+ expect ( parseVersion ( '2.0.1-beta.1' ) ) . toEqual ( { major : 2 , minor : 0 , patch : 1 } ) ;
158+ } ) ;
159+
160+ it ( 'returns null for invalid strings' , ( ) => {
161+ expect ( parseVersion ( 'invalid' ) ) . toBeNull ( ) ;
162+ expect ( parseVersion ( '' ) ) . toBeNull ( ) ;
163+ } ) ;
164+ } ) ;
165+
166+ describe ( 'getVersion' , ( ) => {
167+ it ( 'returns a non-empty string matching VERSION' , ( ) => {
168+ const v = getVersion ( ) ;
169+ expect ( typeof v ) . toBe ( 'string' ) ;
170+ expect ( v . length ) . toBeGreaterThan ( 0 ) ;
171+ expect ( v ) . toBe ( VERSION ) ;
172+ } ) ;
173+ } ) ;
174+
175+ describe ( 'isVersionAtLeast' , ( ) => {
176+ it ( 'returns true when current version meets the minimum' , ( ) => {
177+ // Current VERSION should be at least 1.0.0
178+ expect ( isVersionAtLeast ( '1.0.0' ) ) . toBe ( true ) ;
179+ } ) ;
180+
181+ it ( 'returns true when current version equals the minimum' , ( ) => {
182+ expect ( isVersionAtLeast ( VERSION ) ) . toBe ( true ) ;
183+ } ) ;
184+
185+ it ( 'returns false when minimum is higher than current' , ( ) => {
186+ expect ( isVersionAtLeast ( '999.0.0' ) ) . toBe ( false ) ;
187+ } ) ;
188+
189+ it ( 'returns false for invalid version strings' , ( ) => {
190+ expect ( isVersionAtLeast ( 'invalid' ) ) . toBe ( false ) ;
191+ } ) ;
192+ } ) ;
193+
151194describe ( 'PARALLELISM_LIMITS' , ( ) => {
152195 it ( 'has entries for all 3 profiles' , ( ) => {
153196 expect ( Object . keys ( PARALLELISM_LIMITS ) ) . toHaveLength ( 3 ) ;
0 commit comments