-
Notifications
You must be signed in to change notification settings - Fork 339
/
Copy pathupgradeDependencies.test.ts
61 lines (51 loc) · 2.63 KB
/
upgradeDependencies.test.ts
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
import upgradeDependencies from '../src/lib/upgradeDependencies'
import chaiSetup from './helpers/chaiSetup'
chaiSetup()
describe('upgradeDependencies', () => {
it('upgrade simple, non-semver versions', () => {
upgradeDependencies({ foo: '1' }, { foo: '2' }).should.eql({ foo: '2' })
upgradeDependencies({ foo: '1.0' }, { foo: '1.1' }).should.eql({ foo: '1.1' })
upgradeDependencies({ 'ncu-test-simple-tag': 'v1' }, { 'ncu-test-simple-tag': 'v3' }).should.eql({
'ncu-test-simple-tag': 'v3',
})
})
it('upgrade github dependencies', () => {
upgradeDependencies({ foo: 'github:foo/bar#v1' }, { foo: 'github:foo/bar#v2' }).should.eql({
foo: 'github:foo/bar#v2',
})
upgradeDependencies({ foo: 'github:foo/bar#v1.0' }, { foo: 'github:foo/bar#v2.0' }).should.eql({
foo: 'github:foo/bar#v2.0',
})
upgradeDependencies({ foo: 'github:foo/bar#v1.0.0' }, { foo: 'github:foo/bar#v2.0.0' }).should.eql({
foo: 'github:foo/bar#v2.0.0',
})
})
it('upgrade latest versions that already satisfy the specified version', () => {
upgradeDependencies({ mongodb: '^1.0.0' }, { mongodb: '1.4.30' }).should.eql({
mongodb: '^1.4.30',
})
})
it('do not downgrade', () => {
upgradeDependencies({ mongodb: '^2.0.7' }, { mongodb: '1.4.30' }).should.eql({})
})
it('allow to update to latest via @latest tag', () => {
upgradeDependencies({ mongodb: '^1.5.0-alpha.1' }, { mongodb: '1.4.30' }, { target: '@latest' }).should.eql({
mongodb: '^1.4.30',
})
})
it('use the preferred wildcard when converting <, closed, or mixed ranges', () => {
upgradeDependencies({ a: '1.*', mongodb: '<1.0' }, { mongodb: '3.0.0' }).should.eql({ mongodb: '3.*' })
upgradeDependencies({ a: '1.x', mongodb: '<1.0' }, { mongodb: '3.0.0' }).should.eql({ mongodb: '3.x' })
upgradeDependencies({ a: '~1', mongodb: '<1.0' }, { mongodb: '3.0.0' }).should.eql({ mongodb: '~3.0' })
upgradeDependencies({ a: '^1', mongodb: '<1.0' }, { mongodb: '3.0.0' }).should.eql({ mongodb: '^3.0' })
upgradeDependencies({ a: '1.*', mongodb: '1.0 < 2.0' }, { mongodb: '3.0.0' }).should.eql({ mongodb: '3.*' })
upgradeDependencies({ mongodb: '1.0 < 2.*' }, { mongodb: '3.0.0' }).should.eql({ mongodb: '3.*' })
})
it('convert closed ranges to caret (^) when preferred wildcard is unknown', () => {
upgradeDependencies({ mongodb: '1.0 < 2.0' }, { mongodb: '3.0.0' }).should.eql({ mongodb: '^3.0' })
})
it('ignore packages with empty values', () => {
upgradeDependencies({ mongodb: null }, { mongodb: '1.4.30' }).should.eql({})
upgradeDependencies({ mongodb: '' }, { mongodb: '1.4.30' }).should.eql({})
})
})