|
3 | 3 | * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license |
4 | 4 | */ |
5 | 5 |
|
6 | | -import env, { isEdge, isMac, isGecko, isSafari } from '../src/env'; |
| 6 | +import env, { isEdge, isMac, isGecko, isSafari, isAndroid } from '../src/env'; |
7 | 7 |
|
8 | 8 | function toLowerCase( str ) { |
9 | 9 | return str.toLowerCase(); |
@@ -38,6 +38,12 @@ describe( 'Env', () => { |
38 | 38 | } ); |
39 | 39 | } ); |
40 | 40 |
|
| 41 | + describe( 'isAndroid', () => { |
| 42 | + it( 'is a boolean', () => { |
| 43 | + expect( env.isAndroid ).to.be.a( 'boolean' ); |
| 44 | + } ); |
| 45 | + } ); |
| 46 | + |
41 | 47 | describe( 'isMac()', () => { |
42 | 48 | it( 'returns true for macintosh UA strings', () => { |
43 | 49 | expect( isMac( 'macintosh' ) ).to.be.true; |
@@ -134,4 +140,33 @@ describe( 'Env', () => { |
134 | 140 | } ); |
135 | 141 | /* eslint-enable max-len */ |
136 | 142 | } ); |
| 143 | + |
| 144 | + describe( 'isAndroid()', () => { |
| 145 | + /* eslint-disable max-len */ |
| 146 | + it( 'returns true for Android UA strings', () => { |
| 147 | + // Strings taken from https://developer.chrome.com/multidevice/user-agent. |
| 148 | + expect( isAndroid( toLowerCase( |
| 149 | + 'Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>' |
| 150 | + ) ) ).to.be.true; |
| 151 | + |
| 152 | + expect( isAndroid( toLowerCase( |
| 153 | + 'Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev>(KHTML, like Gecko) Chrome/<Chrome Rev> Safari/<WebKit Rev>' |
| 154 | + ) ) ).to.be.true; |
| 155 | + } ); |
| 156 | + |
| 157 | + it( 'returns false for non-Android UA strings', () => { |
| 158 | + expect( isAndroid( toLowerCase( |
| 159 | + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36' |
| 160 | + ) ) ).to.be.false; |
| 161 | + |
| 162 | + expect( isAndroid( toLowerCase( |
| 163 | + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0' |
| 164 | + ) ) ).to.be.false; |
| 165 | + |
| 166 | + expect( isAndroid( toLowerCase( |
| 167 | + 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko' |
| 168 | + ) ) ).to.be.false; |
| 169 | + } ); |
| 170 | + /* eslint-enable max-len */ |
| 171 | + } ); |
137 | 172 | } ); |
0 commit comments