-
-
Notifications
You must be signed in to change notification settings - Fork 692
/
feature.test.js
53 lines (42 loc) 路 1.15 KB
/
feature.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
let { test } = require('uvu')
let { equal, is, throws } = require('uvu/assert')
delete require.cache[require.resolve('..')]
let browserslist = require('..')
let originCache = browserslist.cache
test.before.each(() => {
browserslist.cache = {}
browserslist.data.and_chr = {
name: 'and_chr',
versions: ['81'],
released: [],
releaseDate: {}
}
})
test.after.each(() => {
browserslist.cache = originCache
})
test('load features from Can I Use', () => {
is(browserslist('supports objectrtc').length > 0, true)
})
test('throw an error on wrong feature name from Can I Use', () => {
throws(() => browserslist('supports wrong-feature-name'), /Unknown feature name/)
})
test('selects browsers by feature', () => {
browserslist.cache = {
rtcpeerconnection: {
'and_chr 81': 'y',
'firefox 2': 'n'
}
}
equal(browserslist('supports rtcpeerconnection'), ['and_chr 81'])
})
test('selects browsers by feature with dashes in its name', () => {
browserslist.cache = {
'arrow-functions': {
'and_chr 81': 'y',
'ie 11': 'n'
}
}
equal(browserslist('supports arrow-functions'), ['and_chr 81'])
})
test.run()