UNPKG

2.12 kBPlain TextView Raw
1import isMobile, { isMobileResult } from '../';
2
3describe('Android', () => {
4 let mobile: isMobileResult;
5 let userAgent: string;
6
7 describe('Phone UserAgent', () => {
8 beforeEach(() => {
9 userAgent =
10 'Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>';
11 mobile = isMobile(userAgent);
12 });
13
14 test('should be an Android Phone', () => {
15 expect(mobile.android.phone).toBe(true);
16 });
17
18 test('should not be an Android Tablet', () => {
19 expect(mobile.android.tablet).not.toBe(true);
20 });
21
22 test('should be matched as Any Phone', () => {
23 expect(mobile.phone).toBe(true);
24 });
25
26 test('should be an Android device', () => {
27 expect(mobile.android.device).toBe(true);
28 });
29 });
30
31 describe('Tablet UserAgent', () => {
32 beforeEach(() => {
33 userAgent =
34 'Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev>(KHTML, like Gecko) Chrome/<Chrome Rev> Safari/<WebKit Rev>';
35 mobile = isMobile(userAgent);
36 });
37
38 test('should not be an Android Phone', () => {
39 expect(mobile.android.phone).not.toBe(true);
40 });
41
42 test('should be an Android Tablet', () => {
43 expect(mobile.android.tablet).toBe(true);
44 });
45
46 test('should be matched as Any Tablet', () => {
47 expect(mobile.tablet).toBe(true);
48 });
49
50 test('should be an Android device', () => {
51 expect(mobile.android.device).toBe(true);
52 });
53 });
54
55 describe('OkHttp UserAgent', () => {
56 beforeEach(() => {
57 userAgent = 'okhttp/3.9.1';
58 mobile = isMobile(userAgent);
59 });
60
61 test('should not be an Android Phone', () => {
62 expect(mobile.android.phone).toBe(false);
63 });
64
65 test('should not be an Android Tablet', () => {
66 expect(mobile.android.tablet).toBe(false);
67 });
68
69 test('should be matched as Any Tablet', () => {
70 expect(mobile.tablet).toBe(false);
71 });
72
73 test('should be an Android device', () => {
74 expect(mobile.android.device).toBe(true);
75 });
76 });
77});