@@ -67,6 +67,12 @@ test("(instance) satisfies", (t) => {
6767 t . is ( new SpecificationVersion ( "2.2" ) . satisfies ( "^2.2" ) , true ) ;
6868 t . is ( new SpecificationVersion ( "2.3" ) . satisfies ( "^2.2" ) , true ) ;
6969
70+ // range: >=2.2
71+ t . is ( new SpecificationVersion ( "2.1" ) . satisfies ( ">=2.2" ) , false ) ;
72+ t . is ( new SpecificationVersion ( "2.2" ) . satisfies ( ">=2.2" ) , true ) ;
73+ t . is ( new SpecificationVersion ( "2.3" ) . satisfies ( ">=2.2" ) , true ) ;
74+ t . is ( new SpecificationVersion ( "3.1" ) . satisfies ( ">=2.2" ) , true ) ;
75+
7076 // range: > 1.0
7177 t . is ( new SpecificationVersion ( "1.0" ) . satisfies ( "> 1.0" ) , false ) ;
7278 t . is ( new SpecificationVersion ( "1.1" ) . satisfies ( "> 1.0" ) , true ) ;
@@ -162,6 +168,12 @@ test("(static) satisfies", (t) => {
162168 t . is ( SpecificationVersion . satisfies ( "2.2" , "^2.2" ) , true ) ;
163169 t . is ( SpecificationVersion . satisfies ( "2.3" , "^2.2" ) , true ) ;
164170
171+ // range: >=2.2
172+ t . is ( SpecificationVersion . satisfies ( "2.1" , ">=2.2" ) , false ) ;
173+ t . is ( SpecificationVersion . satisfies ( "2.2" , ">=2.2" ) , true ) ;
174+ t . is ( SpecificationVersion . satisfies ( "2.3" , ">=2.2" ) , true ) ;
175+ t . is ( SpecificationVersion . satisfies ( "3.1" , ">=2.2" ) , true ) ;
176+
165177 // range: > 1.0
166178 t . is ( SpecificationVersion . satisfies ( "1.0" , "> 1.0" ) , false ) ;
167179 t . is ( SpecificationVersion . satisfies ( "1.1" , "> 1.0" ) , true ) ;
@@ -212,6 +224,45 @@ test("(static) low level comparator", (t) => {
212224 t . is ( SpecificationVersion . neq ( "2.2" , "2.2" ) , false ) ;
213225} ) ;
214226
227+ test ( "(static) getVersionsForRange" , ( t ) => {
228+ // range: 1.x
229+ t . deepEqual ( SpecificationVersion . getVersionsForRange ( "1.x" ) , [
230+ "1.0" , "1.1"
231+ ] ) ;
232+
233+ // range: ^2.2
234+ t . deepEqual ( SpecificationVersion . getVersionsForRange ( "^2.2" ) , [
235+ "2.2" , "2.3" , "2.4" , "2.5" , "2.6"
236+ ] ) ;
237+
238+ // range: >=2.2
239+ t . deepEqual ( SpecificationVersion . getVersionsForRange ( ">=2.2" ) , [
240+ "2.2" , "2.3" , "2.4" , "2.5" , "2.6" ,
241+ "3.0" , "3.1" ,
242+ ] ) ;
243+
244+ // range: > 1.0
245+ t . deepEqual ( SpecificationVersion . getVersionsForRange ( "> 1.0" ) , [
246+ "1.1" ,
247+ "2.0" , "2.1" , "2.2" , "2.3" , "2.4" , "2.5" , "2.6" ,
248+ "3.0" , "3.1" ,
249+ ] ) ;
250+
251+ // range: 2.2 - 2.4
252+ t . deepEqual ( SpecificationVersion . getVersionsForRange ( "2.2 - 2.4" ) , [
253+ "2.2" , "2.3" , "2.4"
254+ ] ) ;
255+
256+ // range: 0.1 || 1.0 - 1.1 || ^2.5
257+ t . deepEqual ( SpecificationVersion . getVersionsForRange ( "0.1 || 1.0 - 1.1 || ^2.5" ) , [
258+ "0.1" , "1.0" , "1.1" ,
259+ "2.5" , "2.6"
260+ ] ) ;
261+
262+ // Incorrect range returns empty array
263+ t . deepEqual ( SpecificationVersion . getVersionsForRange ( "not a range" ) , [ ] ) ;
264+ } ) ;
265+
215266test ( "getSemverCompatibleVersion" , ( t ) => {
216267 t . is ( __localFunctions__ . getSemverCompatibleVersion ( "0.1" ) , "0.1.0" ) ;
217268 t . is ( __localFunctions__ . getSemverCompatibleVersion ( "1.1" ) , "1.1.0" ) ;
0 commit comments