import { isMobile, isNode, isNodeList, transformSupported, transitionSupported } from '../../src/utils/browser'


describe('Browser Utilities', () => {

	describe('isMobile()', () => {

		it('should return true when passed a mobile user agent', () => {

			const android = `Mozilla/5.0 (Linux; U; Android 4.2; en-us;
				Android SDK built for x86 Build/JOP40C) AppleWebKit/534.30
				(KHTML, like Gecko) Version/4.0 Mobile Safari/534.30`

			const iPhone = `Mozilla/5.0 (iPhone; CPU iPhone OS 10_10_5 like Mac OS X)
				AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12B411 Safari/600.1.4`

			expect(isMobile(android)).to.be.true
			expect(isMobile(iPhone)).to.be.true
		})

		it('should return false when passed a desktop user agent', () => {

			const chrome = `Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36
				(KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36`

			const firefox = 'Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Firefox/45.0'

			const ie10 = `Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1;
				WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET4.0C; .NET4.0E)`

			expect(isMobile(chrome)).to.be.false
			expect(isMobile(firefox)).to.be.false
			expect(isMobile(ie10)).to.be.false
		})

		it('should work when not passed an explicit user agent', () => {
			expect(isMobile()).to.be.a('boolean')
		})
	})

	describe('isNode()', () => {

		it('should return true when passed a DOM node', () => {
			const result = isNode(document.querySelector('body'))
			expect(result).to.be.true
		})

		it('should return false when passed HTML as a string', () => {
			const result = isNode('<div class="foo"></div>')
			expect(result).to.be.false
		})
	})

	describe('isNodeList()', () => {

		it('should return true when passed a DOM node list', () => {
			const result = isNodeList(document.querySelectorAll('script'))
			expect(result).to.be.true
		})

		it('should return false when passed an array of HTML elements', () => {
			const elements = document.querySelectorAll('body')
			const result = isNodeList(Array.prototype.slice.call(elements))
			expect(result).to.be.false
		})
	})

	describe('transformSupported()', () => {
		it('should return true', () => {
			expect(transformSupported()).to.be.true
		})
	})

	describe('transitionSupported()', () => {
		it('should return true', () => {
			expect(transitionSupported()).to.be.true
		})
	})
})

@@ -4,81 +4,20 @@
 ort 
-%7B isMobile, isNode, isNodeList, transformSupported, transitionSupported %7D
+* as browser
  fro
@@ -537,32 +537,40 @@
 1.4%60%0A%0A%09%09%09expect(
+browser.
 isMobile(android
@@ -585,32 +585,40 @@
 .true%0A%09%09%09expect(
+browser.
 isMobile(iPhone)
@@ -1078,32 +1078,40 @@
 0E)%60%0A%0A%09%09%09expect(
+browser.
 isMobile(chrome)
@@ -1126,32 +1126,40 @@
 false%0A%09%09%09expect(
+browser.
 isMobile(firefox
@@ -1175,32 +1175,40 @@
 false%0A%09%09%09expect(
+browser.
 isMobile(ie10)).
@@ -1302,16 +1302,24 @@
 %09expect(
+browser.
 isMobile
@@ -1454,24 +1454,32 @@
 st result = 
+browser.
 isNode(docum
@@ -1619,24 +1619,32 @@
 st result = 
+browser.
 isNode('%3Cdiv
@@ -1813,32 +1813,40 @@
 %09const result = 
+browser.
 isNodeList(docum
@@ -2058,16 +2058,24 @@
 esult = 
+browser.
 isNodeLi
@@ -2238,24 +2238,32 @@
 %7B%0A%09%09%09expect(
+browser.
 transformSup
@@ -2363,32 +2363,32 @@
  true', () =%3E %7B%0A
-
 %09%09%09expect(transi
@@ -2381,16 +2381,24 @@
 %09expect(
+browser.
 transiti

add namespace to browser util tests