-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
77 lines (61 loc) · 3.2 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const semverCompare = require('./semver-range').semverCompare;
const semverDiff = require('./semver-range').semverDiff;
const assert = require('assert');
describe('Semver range comparisons', function () {
it('^2.0.0 -> ~2.0.1 is a major downgrade', function () {
assert.equal(semverCompare('^2.0.0', '~2.0.1'), 'downgraded');
assert.equal(semverDiff('^2.0.0', '~2.0.1'), 'major');
});
it('>=2.0.0 -> >=2.0.1 is an upgrade', function () {
assert.equal(semverCompare('>=2.0.0', '>=2.0.1'), 'upgraded');
assert.equal(semverDiff('>=2.0.0', '>=2.0.1'), 'other');
});
it('1.2.3-alpha.3 -> 1.2.3 is a prerelease upgrade', function () {
assert.equal(semverCompare('1.2.3-alpha.3', '1.2.3'), 'upgraded');
assert.equal(semverDiff('1.2.3-alpha.3', '1.2.3'), 'prerelease');
});
it('1.2.3 -> 1.2.3-alpha.3 is a prerelease downgrade', function () {
assert.equal(semverCompare('1.2.3', '1.2.3-alpha.3'), 'downgraded');
assert.equal(semverDiff('1.2.3', '1.2.3-alpha.3'), 'prerelease');
});
it('1.2.3-alpha.3 -> 2.2.3 is a major upgrade', function () {
assert.equal(semverCompare('1.2.3-alpha.3', '2.2.3'), 'upgraded');
assert.equal(semverDiff('1.2.3-alpha.3', '2.2.3'), 'premajor');
});
it('2.2.3 -> 1.2.3-alpha.3 is a premajor downgrade', function () {
assert.equal(semverCompare('2.2.3', '1.2.3-alpha.3'), 'downgraded');
assert.equal(semverDiff('2.2.3', '1.2.3-alpha.3'), 'premajor');
});
it('<=1.1.0 >0.2.0 -> <=0.1.1 >1.2.0 is a major upgrade', function () {
assert.equal(semverCompare('<=1.1.0 >0.2.0', '<=0.1.1 >1.2.0'), 'upgraded');
assert.equal(semverDiff('<=1.1.0 >0.2.0', '<=0.1.1 >1.2.0'), 'major');
});
it('^4.0.x -> 4.x is not_changed', function () {
assert.equal(semverCompare('^4.0.x', '4.x'), 'not_changed');
assert.equal(semverDiff('^4.0.x', '4.x'), 'other');
});
it('4.0.x -> 4.x is a major upgrade', function () {
assert.equal(semverCompare('4.0.x', '4.x'), 'upgraded');
assert.equal(semverDiff('4.0.x', '4.x'), 'major');
});
it('^4.x -> 4.0.x is a major downgrade', function () {
assert.equal(semverCompare('4.x', '4.0.x'), 'downgraded');
assert.equal(semverDiff('4.x', '4.0.x'), 'major');
});
it('4.x -> <URL> is url', function () {
assert.equal(semverCompare('4.x', 'https://github.com/indexzero/forever/tarball/v0.5.6'), 'url');
assert.equal(semverDiff('4.x', 'https://github.com/indexzero/forever/tarball/v0.5.6'), 'url');
});
it('<URL> -> 4.x is url', function () {
assert.equal(semverCompare('https://github.com/indexzero/forever/tarball/v0.5.6', '4.x'), 'url');
assert.equal(semverDiff('https://github.com/indexzero/forever/tarball/v0.5.6', '4.x'), 'url');
});
it('4.0.0 -> 3.0.0 is a major downgrade', function () {
assert.equal(semverCompare('4.0.0', '3.0.0'), 'downgraded');
assert.equal(semverDiff('4.0.0', '3.0.0'), 'major');
});
it('3.0.0 AND 4.0.0 is a major upgrade', function () {
assert.equal(semverCompare('3.0.0', '4.0.0'), 'upgraded');
assert.equal(semverDiff('3.0.0', '4.0.0'), 'major');
});
});