-
Notifications
You must be signed in to change notification settings - Fork 339
/
Copy pathgetPreferredWildcard.test.ts
77 lines (69 loc) · 1.84 KB
/
getPreferredWildcard.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import getPreferredWildcard from '../src/lib/getPreferredWildcard'
import chaiSetup from './helpers/chaiSetup'
const should = chaiSetup()
describe('getPreferredWildcard', () => {
it('identify ^ when it is preferred', () => {
const deps = {
async: '^0.9.0',
bluebird: '^2.9.27',
cint: '^8.2.1',
commander: '~2.8.1',
lodash: '^3.2.0',
}
getPreferredWildcard(deps)!.should.equal('^')
})
it('identify ~ when it is preferred', () => {
const deps = {
async: '~0.9.0',
bluebird: '~2.9.27',
cint: '^8.2.1',
commander: '~2.8.1',
lodash: '^3.2.0',
}
getPreferredWildcard(deps)!.should.equal('~')
})
it('identify .x when it is preferred', () => {
const deps = {
async: '0.9.x',
bluebird: '2.9.x',
cint: '^8.2.1',
commander: '~2.8.1',
lodash: '3.x',
}
getPreferredWildcard(deps)!.should.equal('.x')
})
it('identify .* when it is preferred', () => {
const deps = {
async: '0.9.*',
bluebird: '2.9.*',
cint: '^8.2.1',
commander: '~2.8.1',
lodash: '3.*',
}
getPreferredWildcard(deps)!.should.equal('.*')
})
it('do not allow wildcards to be outnumbered by non-wildcards', () => {
const deps = {
gulp: '^4.0.0',
typescript: '3.3.0',
webpack: '4.30.0',
}
getPreferredWildcard(deps)!.should.equal('^')
})
it('use the first wildcard if there is a tie', () => {
const deps = {
async: '0.9.x',
commander: '2.8.*',
}
getPreferredWildcard(deps)!.should.equal('.x')
})
it('return null when it cannot be determined from other dependencies', () => {
const deps = {
async: '0.9.0',
commander: '2.8.1',
lodash: '3.2.0',
}
should.equal(getPreferredWildcard(deps), null)
should.equal(getPreferredWildcard({}), null)
})
})