From 3ea9d7d969aea640cac21890b561cdc7aea4a46d Mon Sep 17 00:00:00 2001 From: Baris Aydinoglu Date: Sat, 3 Jan 2015 15:41:12 +0200 Subject: [PATCH] Qunit tests updated --- Gruntfile.js | 1 + src/.jshintrc | 45 +++++++++++++++++++++------------------------ test/tests.js | 39 ++++++++++++++++++++++++++++++--------- 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1e3a854..3c6c367 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -48,6 +48,7 @@ module.exports = function(grunt) { src: "src/**/*.js", gruntfile: "Gruntfile.js", tasks: "tasks/*.js", + tests: "test/tests.js", options: { config: ".jscs.json" } diff --git a/src/.jshintrc b/src/.jshintrc index 25cf9d3..02bf193 100644 --- a/src/.jshintrc +++ b/src/.jshintrc @@ -1,26 +1,23 @@ { - "boss": true, - "curly": true, - "eqeqeq": true, - "eqnull": true, - "expr": true, - "immed": true, - "noarg": true, - "onevar": true, - "quotmark": "double", - "smarttabs": true, - "trailing": true, - "undef": true, - "unused": true, - - "sub": true, - - "browser": true, - - "globals": { - "jQuery": true, - "define": true, - "module": true, - "ActiveXObject": true - } + "boss": true, + "curly": true, + "eqeqeq": true, + "eqnull": true, + "expr": true, + "immed": true, + "noarg": true, + "onevar": true, + "quotmark": "double", + "smarttabs": true, + "trailing": true, + "undef": true, + "unused": true, + "sub": true, + "browser": true, + "globals": { + "jQuery": true, + "define": true, + "module": true, + "ActiveXObject": true + } } diff --git a/test/tests.js b/test/tests.js index 450dc58..ecac3da 100644 --- a/test/tests.js +++ b/test/tests.js @@ -3,22 +3,41 @@ var userAgentsToTest = [{ b: 'chrome', bv: '31', os: 'mac os', - osv: '10' + osv: '10', + dt: 'desktop', + dm: 'mac' }, { ua: 'Mozilla/5.0 (Linux; U; Android 4.0.3; de-de; Build/20120717) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30', b: 'safari', bv: '4', os: 'android', - osv: '4' + osv: '4', + dt: 'tablet', + dm: 'android' }, { ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/31.0.1650.18 Mobile/11B554a Safari/8536.25 (3AE36537-DD6D-42A2-ACA6-7F76E297E70F)', b: 'chrome', bv: '31', os: 'ios', - osv: '7' + osv: '7', + dt: 'mobile', + dm: 'iphone' +}, { + ua: 'Mozilla/5.0 (SMART-TV; X11; Linux i686) AppleWebKit/534.7 (KHTML, like Gecko) Version/5.0 Safari/534.7', + b: 'safari', + bv: '5', + os: 'linux', + dt: 'tv', + dm: 'smartTv' }]; -test('is Detectizr ready', function () { +function assertEqual(val1, val2, name) { + if (val2 !== undefined) { + equal(val1, val2, name + " is OK: " + val2); + } +} + +test('is Detectizr ready', function() { notEqual(Detectizr.device, undefined); }); @@ -38,10 +57,12 @@ module("useragent", { } }); for (var i = userAgentsToTest.length - 1; i >= 0; i--) { - test(userAgentsToTest[i].ua, function () { - equal(Detectizr.os.name, useragent2test.os, "operating system name is OK: " + useragent2test.os); - equal(Detectizr.os.major, useragent2test.osv, "operating system name is OK: " + useragent2test.osv); - equal(Detectizr.browser.name, useragent2test.b, "browser name is OK: " + useragent2test.b); - equal(Detectizr.browser.major, useragent2test.bv, "browser version is OK: " + useragent2test.bv); + test(userAgentsToTest[i].ua, function() { + assertEqual(Detectizr.device.type, useragent2test.dt, "device type"); + assertEqual(Detectizr.device.model, useragent2test.dm, "device model"); + assertEqual(Detectizr.os.name, useragent2test.os, "operating system name"); + assertEqual(Detectizr.os.major, useragent2test.osv, "operating system version"); + assertEqual(Detectizr.browser.name, useragent2test.b, "browser name"); + assertEqual(Detectizr.browser.major, useragent2test.bv, "browser version"); }); }