You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
707 B
30 lines
707 B
4 years ago
|
var tap = require('tap');
|
||
|
var test = tap.test;
|
||
|
var semver = require('../semver.js');
|
||
|
var clean = semver.clean;
|
||
|
|
||
|
test('\nclean tests', function(t) {
|
||
|
// [range, version]
|
||
|
// Version should be detectable despite extra characters
|
||
|
[
|
||
|
['1.2.3', '1.2.3'],
|
||
|
[' 1.2.3 ', '1.2.3'],
|
||
|
[' 1.2.3-4 ', '1.2.3-4'],
|
||
|
[' 1.2.3-pre ', '1.2.3-pre'],
|
||
|
[' =v1.2.3 ', '1.2.3'],
|
||
|
['v1.2.3', '1.2.3'],
|
||
|
[' v1.2.3 ', '1.2.3'],
|
||
|
['\t1.2.3', '1.2.3'],
|
||
|
['>1.2.3', null],
|
||
|
['~1.2.3', null],
|
||
|
['<=1.2.3', null],
|
||
|
['1.2.x', null]
|
||
|
].forEach(function(tuple) {
|
||
|
var range = tuple[0];
|
||
|
var version = tuple[1];
|
||
|
var msg = 'clean(' + range + ') = ' + version;
|
||
|
t.equal(clean(range), version, msg);
|
||
|
});
|
||
|
t.end();
|
||
|
});
|