mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-09-27 07:58:45 +03:00
Add a test for issue #8
This commit is contained in:
parent
249dcf0c80
commit
59714adea3
@ -1,7 +1,7 @@
|
||||
{
|
||||
"title": "UA-Parser.JS",
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.5.0",
|
||||
"version": "0.5.1",
|
||||
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||
"keywords": [
|
||||
|
40
test.js
40
test.js
@ -1238,6 +1238,17 @@ var os = [
|
||||
version : ''
|
||||
}
|
||||
}];
|
||||
var devices = [
|
||||
{
|
||||
desc : 'HTC Evo Shift 4G',
|
||||
ua : 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0',
|
||||
expect :
|
||||
{
|
||||
vendor : 'HTC',
|
||||
model : 'Evo Shift 4G',
|
||||
type : 'mobile'
|
||||
}
|
||||
}];
|
||||
|
||||
describe('getBrowser', function () {
|
||||
|
||||
@ -1311,3 +1322,32 @@ describe('getOS', function () {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
describe('getDevice', function () {
|
||||
|
||||
for (var i in devices) {
|
||||
|
||||
if (devices[i].ua) {
|
||||
|
||||
describe('[' + devices[i].desc + ']', function () {
|
||||
describe('"' + devices[i].ua + '"', function () {
|
||||
|
||||
var expect = devices[i].expect;
|
||||
var result = parser.setUA(devices[i].ua).getDevice();
|
||||
|
||||
it('should return device vendor: ' + expect.vendor, function () {
|
||||
assert.equal(result.vendor, expect.vendor);
|
||||
});
|
||||
|
||||
it('should return device model: ' + expect.model, function () {
|
||||
assert.equal(result.model, expect.model);
|
||||
});
|
||||
|
||||
it('should return device type: ' + expect.type, function () {
|
||||
assert.equal(result.type, expect.type);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
10
ua-parser.js
10
ua-parser.js
@ -1,4 +1,4 @@
|
||||
// UA-Parser.JS v0.5.0
|
||||
// UA-Parser.JS v0.5.1
|
||||
// Lightweight JavaScript-based User-Agent string parser
|
||||
// https://github.com/faisalman/ua-parser-js
|
||||
//
|
||||
@ -99,9 +99,7 @@
|
||||
var maps = {
|
||||
|
||||
browser : {
|
||||
|
||||
oldsafari : {
|
||||
|
||||
major : {
|
||||
'1' : ['/85', '/125', '/312'],
|
||||
'2' : ['/412', '/416', '/417', '/419'],
|
||||
@ -121,9 +119,7 @@
|
||||
},
|
||||
|
||||
device : {
|
||||
|
||||
htc : {
|
||||
|
||||
model : {
|
||||
'Evo Shift 4G' : '7373KT'
|
||||
}
|
||||
@ -131,9 +127,7 @@
|
||||
},
|
||||
|
||||
os : {
|
||||
|
||||
windows : {
|
||||
|
||||
version : {
|
||||
'ME' : '4.90',
|
||||
'NT 3.11' : 'NT3.51',
|
||||
@ -251,7 +245,7 @@
|
||||
], [VENDOR, MODEL, [TYPE, CONSOLE]], [
|
||||
|
||||
/(sprint\sapa)(\w+)/i
|
||||
], [[VENDOR, 'HTC'], [MODEL, maps.device.htc.model], [TYPE, MOBILE]], [
|
||||
], [[VENDOR, 'HTC'], [MODEL, mapper.string, maps.device.htc.model], [TYPE, MOBILE]], [
|
||||
/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, // HTC
|
||||
|
||||
/(zte)-(\w+)*/i // ZTE
|
||||
|
4
ua-parser.min.js
vendored
4
ua-parser.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user