forked from browserslist/browserslist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcountry.test.ts
73 lines (59 loc) · 1.68 KB
/
country.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
import browserslist from '../'
let originUsage = browserslist.usage
beforeEach(() => {
browserslist.usage = {
US: {
'ie 8': 1,
'ie 9': 5,
'ie 10': 10.1,
'ie 11': 75
},
XX: {
'and_chr 0': 100
}
}
browserslist.data.and_chr = {
name: 'and_chr',
versions: ['80'],
released: [],
releaseDate: {},
}
})
afterEach(() => {
browserslist.usage = originUsage
})
it('selects browsers by popularity', () => {
expect(browserslist('> 10% in US')).toEqual(['ie 11', 'ie 10'])
})
it('selects popularity by more or equal', () => {
expect(browserslist('>= 5% in US')).toEqual(['ie 11', 'ie 10', 'ie 9'])
})
it('selects browsers by unpopularity', () => {
expect(browserslist('< 5% in US')).toEqual(['ie 8'])
})
it('selects unpopularity by less or equal', () => {
expect(browserslist('<= 5% in US')).toEqual(['ie 9', 'ie 8'])
})
it('works with float', () => {
expect(browserslist('> 10.2% in US')).toEqual(['ie 11'])
})
it('works with float that has a leading dot', () => {
expect(browserslist('> .2% in US')).toEqual(
['ie 11', 'ie 10', 'ie 9', 'ie 8']
)
})
it('fixes country case', () => {
expect(browserslist('> 10.2% in us')).toEqual(['ie 11'])
})
it('loads country from Can I Use', () => {
expect(browserslist('> 1% in RU').length > 0).toBe(true)
})
it('loads continents from Can I Use', () => {
expect(browserslist('> 1% in alt-AS').length > 0).toBe(true)
})
it('allows omission of the space between the > and the percentage', () => {
expect(browserslist('>10% in US').length > 0).toBe(true)
})
it('normalize incorrect caniuse versions for and_*', () => {
expect(browserslist('> 50% in XX')).toEqual(['and_chr 80'])
})