|
@@ -3,16 +3,13 @@
|
|
|
* For licensing, see LICENSE.md.
|
|
* For licensing, see LICENSE.md.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-import env, { isEdge, isMac, isGecko } from '../src/env';
|
|
|
|
|
|
|
+import env, { isEdge, isMac, isGecko, isSafari } from '../src/env';
|
|
|
|
|
|
|
|
function toLowerCase( str ) {
|
|
function toLowerCase( str ) {
|
|
|
return str.toLowerCase();
|
|
return str.toLowerCase();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
describe( 'Env', () => {
|
|
describe( 'Env', () => {
|
|
|
- beforeEach( () => {
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
it( 'is an object', () => {
|
|
it( 'is an object', () => {
|
|
|
expect( env ).to.be.an( 'object' );
|
|
expect( env ).to.be.an( 'object' );
|
|
|
} );
|
|
} );
|
|
@@ -35,6 +32,12 @@ describe( 'Env', () => {
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
|
|
+ describe( 'isSafari', () => {
|
|
|
|
|
+ it( 'is a boolean', () => {
|
|
|
|
|
+ expect( env.isSafari ).to.be.a( 'boolean' );
|
|
|
|
|
+ } );
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
describe( 'isMac()', () => {
|
|
describe( 'isMac()', () => {
|
|
|
it( 'returns true for macintosh UA strings', () => {
|
|
it( 'returns true for macintosh UA strings', () => {
|
|
|
expect( isMac( 'macintosh' ) ).to.be.true;
|
|
expect( isMac( 'macintosh' ) ).to.be.true;
|
|
@@ -103,4 +106,32 @@ describe( 'Env', () => {
|
|
|
) ) ).to.be.false;
|
|
) ) ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
} );
|
|
} );
|
|
|
|
|
+
|
|
|
|
|
+ describe( 'isSafari()', () => {
|
|
|
|
|
+ /* eslint-disable max-len */
|
|
|
|
|
+ it( 'returns true for Safari UA strings', () => {
|
|
|
|
|
+ expect( isSafari( toLowerCase(
|
|
|
|
|
+ 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15'
|
|
|
|
|
+ ) ) ).to.be.true;
|
|
|
|
|
+
|
|
|
|
|
+ expect( isSafari( toLowerCase(
|
|
|
|
|
+ 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1'
|
|
|
|
|
+ ) ) ).to.be.true;
|
|
|
|
|
+ } );
|
|
|
|
|
+
|
|
|
|
|
+ it( 'returns false for non-Safari UA strings', () => {
|
|
|
|
|
+ expect( isSafari( toLowerCase(
|
|
|
|
|
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36'
|
|
|
|
|
+ ) ) ).to.be.false;
|
|
|
|
|
+
|
|
|
|
|
+ expect( isSafari( toLowerCase(
|
|
|
|
|
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0'
|
|
|
|
|
+ ) ) ).to.be.false;
|
|
|
|
|
+
|
|
|
|
|
+ expect( isSafari( toLowerCase(
|
|
|
|
|
+ 'Mozilla/5.0 (Linux; Android 7.1; Mi A1 Build/N2G47H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.83 Mobile Safari/537.36'
|
|
|
|
|
+ ) ) ).to.be.false;
|
|
|
|
|
+ } );
|
|
|
|
|
+ /* eslint-enable max-len */
|
|
|
|
|
+ } );
|
|
|
} );
|
|
} );
|