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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
const isMobile = require('../src/isMobile');
describe('Other Mobile Devices', () => {
let mobile;
let userAgent;
beforeEach(() => {
mobile = null;
userAgent = null;
});
describe('BlackBerry 10', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (BB10; Touch) AppleWebKit/537.35+ (KHTML, like Gecko) Version/10.2.0.1791 Mobile Safari/537.35+';
mobile = isMobile(userAgent);
});
test('should not be a Chrome device', () => {
expect(mobile.other.chrome).not.toBe(true);
});
test('should be a BlackBerry 10 device', () => {
expect(mobile.other.blackberry10).toBe(true);
});
test('should not be a BlackBerry device', () => {
expect(mobile.other.blackberry).not.toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('BlackBerry', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+';
mobile = isMobile(userAgent);
});
test('should not be a Chrome device', () => {
expect(mobile.other.chrome).not.toBe(true);
});
test('should be a BlackBerry device', () => {
expect(mobile.other.blackberry).toBe(true);
});
test('should not be a BlackBerry 10 device', () => {
expect(mobile.other.blackberry10).not.toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Opera Mini', () => {
beforeEach(() => {
userAgent =
'Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54';
mobile = isMobile(userAgent);
});
test('should not be a Chrome device', () => {
expect(mobile.other.chrome).not.toBe(true);
});
test('should be an Opera Mini device', () => {
expect(mobile.other.opera).toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Firefox OS', () => {
beforeEach(() => {
userAgent = 'Mozilla/5.0 (Mobile; rv:14.0) Gecko/14.0 Firefox/14.0';
mobile = isMobile(userAgent);
});
test('should not be a Chrome device', () => {
expect(mobile.other.chrome).not.toBe(true);
});
test('should be a Firefox OS device', () => {
expect(mobile.other.firefox).toBe(true);
});
test('should not be an Android device', () => {
expect(mobile.android.device).not.toBe(true);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
describe('Chrome', () => {
beforeEach(() => {
userAgent =
'Mozilla/5.0 (Linux; Android 4.4.4; en-us; Nexus 4 Build/JOP40D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2307.2 Mobile Safari/537.36';
mobile = isMobile(userAgent);
});
test('should be a Chrome device', () => {
expect(mobile.other.chrome).toBe(true);
});
test('should be an Android device', () => {
expect(mobile.android.device).toBe(true);
});
test('should not be a Firefox OS device', () => {
expect(mobile.other.firefox).toBe(false);
});
test('should not be an Apple device', () => {
expect(mobile.apple.device).not.toBe(true);
});
test('should be a mobile device', () => {
expect(mobile.any).toBe(true);
});
});
});