-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
67 lines (60 loc) · 1.45 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
'use strict'
const test = require('tape')
const names = require('.')
test('names', function (t) {
const expected = [
'firefox',
'mozilla firefox',
'mozilla_firefox',
'mozilla-firefox',
'mozillafirefox',
'ff'
]
for (const name of expected) {
t.same(names(name), expected)
t.same(names(name.toUpperCase()), expected)
}
t.same(names('does not exist'), [])
t.end()
})
test('common', function (t) {
t.is(names.common('android_chrome'), 'and_chr')
t.is(names.common('android_chrOme'), 'and_chr')
t.is(names.common('ipad'), undefined)
t.isNot(names.common.all(), names.common.all(), 'unique copy')
t.same(names.common.all().sort(), [
'and_chr',
'android',
'beaker',
'brave',
'chrome',
'edge',
'electron',
'firefox',
'ie',
'ios_saf',
'maxthon',
'node',
'opera',
'opera_mini',
'opera_mobile',
'safari',
'yandex'
])
t.is(names.common('does not exist'), undefined)
t.end()
})
test('title', function (t) {
t.isNot(names.title.all(), names.title.all(), 'unique copy')
t.is(names.title.all().length, names.common.all().length)
t.is(names.title('iphone'), undefined)
t.is(names.title('IOS SAFARI'), 'iOS Safari')
t.is(names.title('and_chr'), 'Google Chrome for Android')
t.is(names.title('does not exist'), undefined)
t.end()
})
test('all', function (t) {
t.ok(Array.isArray(names.all()))
t.isNot(names.all(), names.all(), 'unique copy')
t.end()
})