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
78
79
80
81
82
const isMobile = require('../src/isMobile');
describe('Android', () => {
let mobile;
let userAgent;
beforeEach(() => {
mobile = null;
userAgent = null;
});
describe('Phone UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>';
mobile = isMobile(userAgent);
});
test('should be an Android Phone', () => {
expect(mobile.android.phone).toBe(true);
});
test('should not be an Android Tablet', () => {
expect(mobile.android.tablet).not.toBe(true);
});
test('should be matched as Any Phone', () => {
expect(mobile.phone).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('Tablet UserAgent', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev>(KHTML, like Gecko) Chrome/<Chrome Rev> Safari/<WebKit Rev>';
mobile = isMobile(userAgent);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).not.toBe(true);
});
test('should be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(true);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
describe('OkHttp UserAgent', () => {
beforeEach(() => {
userAgent = 'okhttp/3.9.1';
mobile = isMobile(userAgent);
});
test('should not be an Android Phone', () => {
expect(mobile.android.phone).toBe(false);
});
test('should not be an Android Tablet', () => {
expect(mobile.android.tablet).toBe(false);
});
test('should be matched as Any Tablet', () => {
expect(mobile.tablet).toBe(false);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
});
});