-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test.js
66 lines (57 loc) · 1.81 KB
/
index.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
const test = require('ava');
const parser = require('ua-parser-js');
const {chrome, chromeAdvanced, firefox, firefoxAdvanced, opera, operaAdvanced, safari, safariAdvanced} = require('.');
test('Chrome', t => {
const version = '41.0.2228.0';
const ua = parser(chrome(version));
t.is(ua.browser.name, 'Chrome');
t.is(ua.browser.version, version);
});
test('Chrome Advanced', t => {
const version = '41.0.2228.0';
const webkitVersion = '537.36';
const ua = parser(chromeAdvanced(version, webkitVersion));
t.is(ua.browser.name, 'Chrome');
t.is(ua.browser.version, version);
});
test('Firefox', t => {
const version = '41.0';
const ua = parser(firefox(version));
t.is(ua.browser.name, 'Firefox');
t.is(ua.browser.version, version);
});
test('Firefox Advanced', t => {
const version = '41.0';
const geckoVersion = '20100101';
const ua = parser(firefoxAdvanced(version, geckoVersion));
t.is(ua.browser.name, 'Firefox');
t.is(ua.browser.version, version);
});
test('Opera', t => {
const version = '12.6';
const ua = parser(opera(version));
t.is(ua.browser.name, 'Opera');
t.is(ua.browser.version, version);
});
test('Opera Advanced', t => {
const version = '12.6';
const prestoVersion = '2.12.388';
const operaVersion = '9.80';
const ua = parser(operaAdvanced(version, prestoVersion, operaVersion));
t.is(ua.browser.name, 'Opera');
t.is(ua.browser.version, version);
});
test('Safari', t => {
const version = '10.0.3';
const ua = parser(safari(version));
t.is(ua.browser.name, 'Safari');
t.is(ua.browser.version, version);
});
test('Safari Advanced', t => {
const version = '10.0.3';
const webkitBuildVersion = '602.4.8';
const safariBuildVersion = '602.4.8';
const ua = parser(safariAdvanced(version, webkitBuildVersion, safariBuildVersion));
t.is(ua.browser.name, 'Safari');
t.is(ua.browser.version, version);
});