1 | import isMobile, { isMobileResult } from '../';
|
2 |
|
3 | describe('Windows', () => {
|
4 | let mobile: isMobileResult;
|
5 | let userAgent: string;
|
6 |
|
7 | describe('Windows Phone UserAgent', () => {
|
8 | beforeEach(() => {
|
9 | userAgent =
|
10 | 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)';
|
11 | mobile = isMobile(userAgent);
|
12 | });
|
13 |
|
14 | test('should be a Windows Phone device', () => {
|
15 | expect(mobile.windows.phone).toBe(true);
|
16 | });
|
17 |
|
18 | test('should not be an Android device', () => {
|
19 | expect(mobile.android.device).not.toBe(true);
|
20 | });
|
21 |
|
22 | test('should not be an Apple device', () => {
|
23 | expect(mobile.apple.device).not.toBe(true);
|
24 | });
|
25 |
|
26 | test('should be matched as Any Phone', () => {
|
27 | expect(mobile.phone).toBe(true);
|
28 | });
|
29 |
|
30 | test('should be a mobile device', () => {
|
31 | expect(mobile.any).toBe(true);
|
32 | });
|
33 | });
|
34 |
|
35 | describe('Windows 8.1 Phone UserAgent', () => {
|
36 | beforeEach(() => {
|
37 | userAgent =
|
38 | '//Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 930) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537';
|
39 | mobile = isMobile(userAgent);
|
40 | });
|
41 |
|
42 | test('should be a Windows Phone device', () => {
|
43 | expect(mobile.windows.phone).toBe(true);
|
44 | });
|
45 |
|
46 | test('should not be an Android device', () => {
|
47 | expect(mobile.android.device).not.toBe(true);
|
48 | });
|
49 |
|
50 | test('should not be an Apple device', () => {
|
51 | expect(mobile.apple.device).not.toBe(true);
|
52 | });
|
53 |
|
54 | test('should be matched as Any Phone', () => {
|
55 | expect(mobile.phone).toBe(true);
|
56 | });
|
57 |
|
58 | test('should be a mobile device', () => {
|
59 | expect(mobile.any).toBe(true);
|
60 | });
|
61 | });
|
62 |
|
63 | describe('Windows Edge Phone UserAgent', () => {
|
64 | beforeEach(() => {
|
65 | userAgent =
|
66 | 'Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; <Manufacturer>; <Device>) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10166';
|
67 | mobile = isMobile(userAgent);
|
68 | });
|
69 |
|
70 | test('should be a Windows Phone device', () => {
|
71 | expect(mobile.windows.phone).toBe(true);
|
72 | });
|
73 |
|
74 | test('should not be an Android device', () => {
|
75 | expect(mobile.android.device).not.toBe(true);
|
76 | });
|
77 |
|
78 | test('should not be an Apple device', () => {
|
79 | expect(mobile.apple.device).not.toBe(true);
|
80 | });
|
81 |
|
82 | test('should be matched as Any Phone', () => {
|
83 | expect(mobile.phone).toBe(true);
|
84 | });
|
85 |
|
86 | test('should be a mobile device', () => {
|
87 | expect(mobile.any).toBe(true);
|
88 | });
|
89 | });
|
90 |
|
91 | describe('Windows Tablet UserAgent', () => {
|
92 | beforeEach(() => {
|
93 | userAgent =
|
94 | 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0; Touch)';
|
95 | mobile = isMobile(userAgent);
|
96 | });
|
97 |
|
98 | test('should be a Windows Tablet device', () => {
|
99 | expect(mobile.windows.tablet).toBe(true);
|
100 | });
|
101 |
|
102 | test('should not be a Windows Phone device', () => {
|
103 | expect(mobile.windows.phone).not.toBe(true);
|
104 | });
|
105 |
|
106 | test('should not be an Android device', () => {
|
107 | expect(mobile.android.device).not.toBe(true);
|
108 | });
|
109 |
|
110 | test('should not be an Apple device', () => {
|
111 | expect(mobile.apple.device).not.toBe(true);
|
112 | });
|
113 |
|
114 | test('should be matched as Any Tablet', () => {
|
115 | expect(mobile.tablet).toBe(true);
|
116 | });
|
117 |
|
118 | test('should be a mobile device', () => {
|
119 | expect(mobile.any).toBe(true);
|
120 | });
|
121 | });
|
122 |
|
123 | describe('Windows Touch Laptop UserAgent', () => {
|
124 | beforeEach(() => {
|
125 | userAgent =
|
126 | 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; Touch; MAGWJS; rv:11.0) like Gecko';
|
127 | mobile = isMobile(userAgent);
|
128 | });
|
129 |
|
130 | test('should not be a Windows Tablet device', () => {
|
131 | expect(mobile.windows.tablet).not.toBe(true);
|
132 | });
|
133 |
|
134 | test('should not be a Windows Phone device', () => {
|
135 | expect(mobile.windows.phone).not.toBe(true);
|
136 | });
|
137 |
|
138 | test('should not be an Android device', () => {
|
139 | expect(mobile.android.device).not.toBe(true);
|
140 | });
|
141 |
|
142 | test('should not be an Apple device', () => {
|
143 | expect(mobile.apple.device).not.toBe(true);
|
144 | });
|
145 |
|
146 | test('should not be matched as Any Tablet', () => {
|
147 | expect(mobile.tablet).not.toBe(true);
|
148 | });
|
149 |
|
150 | test('should not be a mobile device', () => {
|
151 | expect(mobile.any).not.toBe(true);
|
152 | });
|
153 | });
|
154 | });
|