33 * For licensing, see LICENSE.md.
44 */
55
6- import env , { isEdge , isMac } from '../src/env' ;
6+ import env , { isEdge , isMac , isGecko } from '../src/env' ;
77
88function toLowerCase ( str ) {
99 return str . toLowerCase ( ) ;
@@ -29,6 +29,12 @@ describe( 'Env', () => {
2929 } ) ;
3030 } ) ;
3131
32+ describe ( 'isGecko' , ( ) => {
33+ it ( 'is a boolean' , ( ) => {
34+ expect ( env . isGecko ) . to . be . a ( 'boolean' ) ;
35+ } ) ;
36+ } ) ;
37+
3238 describe ( 'isMac()' , ( ) => {
3339 it ( 'returns true for macintosh UA strings' , ( ) => {
3440 expect ( isMac ( 'macintosh' ) ) . to . be . true ;
@@ -75,4 +81,26 @@ describe( 'Env', () => {
7581 ) ) ) . to . be . false ;
7682 } ) ;
7783 } ) ;
84+
85+ describe ( 'isGecko()' , ( ) => {
86+ it ( 'returns true for Firefox UA strings' , ( ) => {
87+ expect ( isGecko ( 'gecko/42' ) ) . to . be . true ;
88+ expect ( isGecko ( 'foo gecko/42 bar' ) ) . to . be . true ;
89+
90+ expect ( isGecko ( toLowerCase (
91+ 'mozilla/5.0 (macintosh; intel mac os x 10.13; rv:62.0) gecko/20100101 firefox/62.0'
92+ ) ) ) . to . be . true ;
93+ } ) ;
94+
95+ it ( 'returns false for non–Edge UA strings' , ( ) => {
96+ expect ( isGecko ( '' ) ) . to . be . false ;
97+ expect ( isGecko ( 'foo' ) ) . to . be . false ;
98+ expect ( isGecko ( 'Mozilla' ) ) . to . be . false ;
99+
100+ // Chrome
101+ expect ( isGecko ( toLowerCase (
102+ 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36'
103+ ) ) ) . to . be . false ;
104+ } ) ;
105+ } ) ;
78106} ) ;
0 commit comments