UNPKG

4.24 kBPlain TextView Raw
1import isMobile, { isMobileResult } from '../';
2
3describe('Other Mobile Devices', () => {
4 let mobile: isMobileResult;
5 let userAgent: string;
6
7 describe('BlackBerry 10', () => {
8 beforeEach(() => {
9 userAgent =
10 'Mozilla/5.0 (BB10; Touch) AppleWebKit/537.35+ (KHTML, like Gecko) Version/10.2.0.1791 Mobile Safari/537.35+';
11 mobile = isMobile(userAgent);
12 });
13
14 test('should not be a Chrome device', () => {
15 expect(mobile.other.chrome).not.toBe(true);
16 });
17
18 test('should be a BlackBerry 10 device', () => {
19 expect(mobile.other.blackberry10).toBe(true);
20 });
21
22 test('should not be a BlackBerry device', () => {
23 expect(mobile.other.blackberry).not.toBe(true);
24 });
25
26 test('should not be an Android device', () => {
27 expect(mobile.android.device).not.toBe(true);
28 });
29
30 test('should not be an Apple device', () => {
31 expect(mobile.apple.device).not.toBe(true);
32 });
33
34 test('should be a mobile device', () => {
35 expect(mobile.any).toBe(true);
36 });
37 });
38
39 describe('BlackBerry', () => {
40 beforeEach(() => {
41 userAgent =
42 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.346 Mobile Safari/534.11+';
43 mobile = isMobile(userAgent);
44 });
45
46 test('should not be a Chrome device', () => {
47 expect(mobile.other.chrome).not.toBe(true);
48 });
49
50 test('should be a BlackBerry device', () => {
51 expect(mobile.other.blackberry).toBe(true);
52 });
53
54 test('should not be a BlackBerry 10 device', () => {
55 expect(mobile.other.blackberry10).not.toBe(true);
56 });
57
58 test('should not be an Android device', () => {
59 expect(mobile.android.device).not.toBe(true);
60 });
61
62 test('should not be an Apple device', () => {
63 expect(mobile.apple.device).not.toBe(true);
64 });
65
66 test('should be a mobile device', () => {
67 expect(mobile.any).toBe(true);
68 });
69 });
70
71 describe('Opera Mini', () => {
72 beforeEach(() => {
73 userAgent =
74 'Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54';
75 mobile = isMobile(userAgent);
76 });
77
78 test('should not be a Chrome device', () => {
79 expect(mobile.other.chrome).not.toBe(true);
80 });
81
82 test('should be an Opera Mini device', () => {
83 expect(mobile.other.opera).toBe(true);
84 });
85
86 test('should not be an Android device', () => {
87 expect(mobile.android.device).not.toBe(true);
88 });
89
90 test('should not be an Apple device', () => {
91 expect(mobile.apple.device).not.toBe(true);
92 });
93
94 test('should be a mobile device', () => {
95 expect(mobile.any).toBe(true);
96 });
97 });
98
99 describe('Firefox OS', () => {
100 beforeEach(() => {
101 userAgent = 'Mozilla/5.0 (Mobile; rv:14.0) Gecko/14.0 Firefox/14.0';
102 mobile = isMobile(userAgent);
103 });
104
105 test('should not be a Chrome device', () => {
106 expect(mobile.other.chrome).not.toBe(true);
107 });
108
109 test('should be a Firefox OS device', () => {
110 expect(mobile.other.firefox).toBe(true);
111 });
112
113 test('should not be an Android device', () => {
114 expect(mobile.android.device).not.toBe(true);
115 });
116
117 test('should not be an Apple device', () => {
118 expect(mobile.apple.device).not.toBe(true);
119 });
120
121 test('should be a mobile device', () => {
122 expect(mobile.any).toBe(true);
123 });
124 });
125
126 describe('Chrome', () => {
127 beforeEach(() => {
128 userAgent =
129 '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';
130 mobile = isMobile(userAgent);
131 });
132
133 test('should be a Chrome device', () => {
134 expect(mobile.other.chrome).toBe(true);
135 });
136
137 test('should be an Android device', () => {
138 expect(mobile.android.device).toBe(true);
139 });
140
141 test('should not be a Firefox OS device', () => {
142 expect(mobile.other.firefox).toBe(false);
143 });
144
145 test('should not be an Apple device', () => {
146 expect(mobile.apple.device).not.toBe(true);
147 });
148
149 test('should be a mobile device', () => {
150 expect(mobile.any).toBe(true);
151 });
152 });
153});