From 076ee810bd0ec6b2e902fb62e1093e6337dbaa0c Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Sun, 20 Aug 2017 18:21:17 +0300 Subject: [PATCH] Setup acceptance tests with list of UAs --- package.json | 4 +- test/acceptance/test-list-of-ua.js | 16 ++ .../acceptance/useragentstrings.yml | 193 +++++++++--------- 3 files changed, 115 insertions(+), 98 deletions(-) create mode 100644 test/acceptance/test-list-of-ua.js rename useragentstrings.yml => test/acceptance/useragentstrings.yml (98%) diff --git a/package.json b/package.json index 7668d2f..8be6e24 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "babel-preset-env": "^1.5.2", "babel-register": "^6.24.1", "sinon": "^2.1.0", - "testem": "^1.16.2" + "testem": "^1.16.2", + "yamljs": "^0.3.0" }, "ava": { "require": [ @@ -42,6 +43,7 @@ }, "scripts": { "test": "testem", + "watch-tests": "./node_modules/.bin/ava --watch", "prepublish": "make boosh" }, "license": "MIT" diff --git a/test/acceptance/test-list-of-ua.js b/test/acceptance/test-list-of-ua.js new file mode 100644 index 0000000..9d3c871 --- /dev/null +++ b/test/acceptance/test-list-of-ua.js @@ -0,0 +1,16 @@ +import test from 'ava'; +import yaml from 'yamljs'; +import path from 'path'; +import Bowser from '../../src/new-bowser'; + +const listOfUA = yaml.load(path.join(__dirname, 'useragentstrings.yml')); + +test('Check all the test browsers', t => { + for (const browserName in listOfUA) { + listOfUA[browserName].forEach((browser) => { + const parsed = new Bowser(browser.ua).parse().getResult(); + t.deepEqual(parsed, browser.spec, `${browser.ua}`); + t.is(parsed.browser.name, browserName, `${browser.ua}`); + }); + } +}); diff --git a/useragentstrings.yml b/test/acceptance/useragentstrings.yml similarity index 98% rename from useragentstrings.yml rename to test/acceptance/useragentstrings.yml index 64591c6..b44dc5d 100644 --- a/useragentstrings.yml +++ b/test/acceptance/useragentstrings.yml @@ -1188,6 +1188,76 @@ engine: name: "Trident" version: "7.0" + - + ua: "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920; Vodafone)" + spec: + browser: + name: "Internet Explorer" + version: "10.0" + os: + name: "Windows Phone" + version: "8.0" + platform: + type: "mobile" + engine: + name: "Trident" + version: "6.0" + - + ua: "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)" + spec: + browser: + name: "Internet Explorer" + version: "10.0" + os: + name: "Windows Phone" + version: "8.0" + platform: + type: "mobile" + engine: + name: "Trident" + version: "6.0" + - + ua: "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)" + spec: + browser: + name: "Internet Explorer" + version: "9.0" + os: + name: "Windows Phone" + version: "7.5" + platform: + type: "mobile" + engine: + name: "Trident" + version: "5.0" + - + ua: "Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; Nokia;N70)" + spec: + browser: + name: "Internet Explorer" + version: "7.0" + os: + name: "Windows Phone" + version: "7.0" + platform: + type: "mobile" + engine: + name: "Trident" + version: "3.1" + - + ua: "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; Lumia 640 LTE) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537" + spec: + browser: + name: "Internet Explorer" + version: "11.0" + os: + name: "Windows Phone" + version: "8.1" + platform: + type: "mobile" + engine: + name: "Trident" + version: "7.0" Microsoft Edge: - ua: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0" @@ -1204,6 +1274,20 @@ engine: name: "EdgeHTML" version: "12.0" + - + ua: "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; DEVICE INFO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Mobile Safari/537.36 Edge/12.0" + spec: + browser: + name: "Microsoft Edge" + version: "12.0" + os: + name: "Windows Phone" + version: "10.0" + platform: + type: "mobile" + engine: + name: "EdgeHTML" + version: "12.0" Firefox: - ua: "Mozilla/5.0 (Mobile; rv:26.0) Gecko/26.0 Firefox/26.0" @@ -1652,92 +1736,7 @@ type: "mobile" vendor: "BlackBerry" engine: {} - Windows Phone: - - - ua: "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920; Vodafone)" - spec: - browser: - name: "Internet Explorer" - version: "10.0" - os: - name: "Windows Phone" - version: "8.0" - platform: - type: "mobile" - engine: - name: "Trident" - version: "6.0" - - - ua: "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920)" - spec: - browser: - name: "Internet Explorer" - version: "10.0" - os: - name: "Windows Phone" - version: "8.0" - platform: - type: "mobile" - engine: - name: "Trident" - version: "6.0" - - - ua: "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)" - spec: - browser: - name: "Internet Explorer" - version: "9.0" - os: - name: "Windows Phone" - version: "7.5" - platform: - type: "mobile" - engine: - name: "Trident" - version: "5.0" - - - ua: "Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; Nokia;N70)" - spec: - browser: - name: "Internet Explorer" - version: "7.0" - os: - name: "Windows Phone" - version: "7.0" - platform: - type: "mobile" - engine: - name: "Trident" - version: "3.1" - - - ua: "Mozilla/5.0 (Windows Phone 10.0; Android 4.2.1; DEVICE INFO) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Mobile Safari/537.36 Edge/12.0" - spec: - browser: - name: "Microsoft Edge" - version: "12.0" - os: - name: "Windows Phone" - version: "10.0" - platform: - type: "mobile" - engine: - name: "EdgeHTML" - version: "12.0" - - - ua: "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; Microsoft; Lumia 640 LTE) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537" - spec: - browser: - name: "Internet Explorer" - version: "11.0" - os: - name: "Windows Phone" - version: "8.1" - platform: - type: "mobile" - engine: - name: "Trident" - version: "7.0" - WebOS: + WebOS Browser: - ua: "Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.5; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/234.83 Safari/534.6 TouchPad/1.0" spec: @@ -1819,12 +1818,12 @@ engine: name: "WebKit" version: "525.27.1" - Android: + Android Browser: - ua: "Mozilla/5.0 (Linux; U; Android 4.4.2; de-de; Nexus 7 Build/KOT49H) AppleWebKit/537.16 (KHTML, like Gecko) Version/4.0 Mobile Safari/537.16" spec: browser: - name: "Safari" + name: "Android Browser" version: "4.0" os: name: "Android" @@ -1839,7 +1838,7 @@ ua: "Mozilla/5.0 (Linux; U; Android 4.3; de-de; Galaxy Nexus Build/JWR66Y) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30" spec: browser: - name: "Safari" + name: "Android Browser" version: "4.0" os: name: "Android" @@ -1854,7 +1853,7 @@ ua: "Mozilla/5.0 (Linux; U; Android 4.2; en-us; Nexus 10 Build/JVP15I) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30" spec: browser: - name: "Safari" + name: "Android Browser" version: "4.0" os: name: "Android" @@ -1869,7 +1868,7 @@ ua: "Mozilla/5.0 (Linux; U; Android 3.2; de-de; A100 Build/HTJ85B) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13" spec: browser: - name: "Safari" + name: "Android Browser" version: "4.0" os: name: "Android" @@ -1883,7 +1882,7 @@ ua: "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1" spec: browser: - name: "Safari" + name: "Android Browser" version: "4.0" os: name: "Android" @@ -1897,7 +1896,7 @@ ua: "Mozilla/5.0 (Linux; U; Android 1.6; ar-us; SonyEricssonX10i Build/R2BA026) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1" spec: browser: - name: "Safari" + name: "Android Browser" version: "3.1.2" os: name: "Android" @@ -2026,8 +2025,8 @@ ua: "Mozilla/5.0 (Maemo; Linux; U; Jolla; Sailfish; Mobile; rv:26.0) Gecko/26.0 Firefox/26.0 SailfishBrowser/1.0 like Safari/538.1" spec: browser: - name: "Firefox" - version: "26.0" + name: "Sailfish" + version: "1.0" os: name: "Linux" platform: @@ -2039,8 +2038,8 @@ ua: "Mozilla/5.0 (Linux; U; Jolla; Sailfish; Mobile; rv:20.0) Gecko/20.0 Firefox/20.0 Sailfish Browser/1.0 like Safari/535.19" spec: browser: - name: "Firefox" - version: "20.0" + name: "Sailfish" + version: "1.0" os: name: "Linux" platform: