mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-20 17:16:40 +03:00
Add a test for issue #8
This commit is contained in:
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);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user