|
1 | | -import { isNode, isNodeList, transformSupported, transitionSupported } from '../../src/utils/browser' |
| 1 | +import { isMobile, isNode, isNodeList, transformSupported, transitionSupported } from '../../src/utils/browser' |
2 | 2 |
|
3 | 3 |
|
4 | 4 | describe('Browser Utilities', () => { |
5 | 5 |
|
| 6 | + describe('isMobile()', () => { |
| 7 | + |
| 8 | + it('should return true when passed a mobile user agent', () => { |
| 9 | + |
| 10 | + const android = `Mozilla/5.0 (Linux; U; Android 4.2; en-us; |
| 11 | + Android SDK built for x86 Build/JOP40C) AppleWebKit/534.30 |
| 12 | + (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30` |
| 13 | + |
| 14 | + const iPhone = `Mozilla/5.0 (iPhone; CPU iPhone OS 10_10_5 like Mac OS X) |
| 15 | + AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4` |
| 16 | + |
| 17 | + expect(isMobile(android)).to.be.true |
| 18 | + expect(isMobile(iPhone)).to.be.true |
| 19 | + }) |
| 20 | + |
| 21 | + it('should return false when passed a desktop user agent', () => { |
| 22 | + |
| 23 | + const chrome = `Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 |
| 24 | + (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36` |
| 25 | + |
| 26 | + const firefox = `Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; |
| 27 | + WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E)` |
| 28 | + |
| 29 | + expect(isMobile(chrome)).to.be.false |
| 30 | + expect(isMobile(firefox)).to.be.false |
| 31 | + }) |
| 32 | + |
| 33 | + it('should work when not passed an explicit user agent', () => { |
| 34 | + expect(isMobile()).to.be.a('boolean') |
| 35 | + }) |
| 36 | + }) |
| 37 | + |
6 | 38 | describe('isNode()', () => { |
7 | 39 |
|
8 | 40 | it('should return true when passed a DOM node', () => { |
|
0 commit comments