-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6086e5a
commit b99ae3b
Showing
3 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
var tap = require('tap') | ||
var test = tap.test | ||
var semver = require('../semver.js') | ||
|
||
test('\nminimum version in range tests', function (t) { | ||
// [range, minimum, loose] | ||
[ | ||
// Stars | ||
['*', '0.0.0'], | ||
['* || >=2', '0.0.0'], | ||
['>=2 || *', '0.0.0'], | ||
['>2 || *', '0.0.0'], | ||
|
||
// equal | ||
['1.0.0', '1.0.0'], | ||
['1.0', '1.0.0'], | ||
['1.0.x', '1.0.0'], | ||
['1.0.*', '1.0.0'], | ||
['1', '1.0.0'], | ||
['1.x.x', '1.0.0'], | ||
['1.x.x', '1.0.0'], | ||
['1.*.x', '1.0.0'], | ||
['1.x.*', '1.0.0'], | ||
['1.x', '1.0.0'], | ||
['1.*', '1.0.0'], | ||
['=1.0.0', '1.0.0'], | ||
|
||
// Tilde | ||
['~1.1.1', '1.1.1'], | ||
['~1.1.1-beta', '1.1.1-beta'], | ||
['~1.1.1 || >=2', '1.1.1'], | ||
|
||
// Carot | ||
['^1.1.1', '1.1.1'], | ||
['^1.1.1-beta', '1.1.1-beta'], | ||
['^1.1.1 || >=2', '1.1.1'], | ||
|
||
// '-' operator | ||
['1.1.1 - 1.8.0', '1.1.1'], | ||
['1.1 - 1.8.0', '1.1.0'], | ||
|
||
// Less / less or equal | ||
['<2', '0.0.0'], | ||
['<0.0.0-beta', '0.0.0-0'], | ||
['<0.0.1-beta', '0.0.0'], | ||
['<2 || >4', '0.0.0'], | ||
['>4 || <2', '0.0.0'], | ||
['<=2 || >=4', '0.0.0'], | ||
['>=4 || <=2', '0.0.0'], | ||
['<0.0.0-beta >0.0.0-alpha', '0.0.0-alpha.0'], | ||
['>0.0.0-alpha <0.0.0-beta', '0.0.0-alpha.0'], | ||
|
||
// Greater than or equal | ||
['>=1.1.1 <2 || >=2.2.2 <2', '1.1.1'], | ||
['>=2.2.2 <2 || >=1.1.1 <2', '1.1.1'], | ||
|
||
// Greater than but not equal | ||
['>1.0.0', '1.0.1'], | ||
['>1.0.0-0', '1.0.0-0.0'], | ||
['>1.0.0-beta', '1.0.0-beta.0'], | ||
['>2 || >1.0.0', '1.0.1'], | ||
['>2 || >1.0.0-0', '1.0.0-0.0'], | ||
['>2 || >1.0.0-beta', '1.0.0-beta.0'], | ||
|
||
// Impossible range | ||
['>4 <3', null] | ||
].forEach(function (tuple) { | ||
var range = tuple[0] | ||
var version = tuple[1] | ||
var loose = tuple[2] || false | ||
var msg = 'minVersion(' + range + ', ' + loose + ') = ' + version | ||
var min = semver.minVersion(range, loose) | ||
t.ok(min === version || (min && min.version === version), msg) | ||
}) | ||
t.end() | ||
}) |