Skip to content

Commit

Permalink
Qunit tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
barisaydinoglu committed Jan 3, 2015
1 parent 2cb7685 commit 3ea9d7d
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 33 deletions.
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
45 changes: 21 additions & 24 deletions src/.jshintrc
Original file line number Diff line number Diff line change
@@ -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
}
}
39 changes: 30 additions & 9 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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");
});
}

0 comments on commit 3ea9d7d

Please sign in to comment.