ua-tests.js revision 4eeb28ea335313c708fe2730312f94978b07dd04
f305b4cc9d93cbb567843dd3547c8900fbbcd7e7Eric FerraiuoloYUI.add('ua-tests', function(Y) {
f305b4cc9d93cbb567843dd3547c8900fbbcd7e7Eric Ferraiuolo
f305b4cc9d93cbb567843dd3547c8900fbbcd7e7Eric Ferraiuolo
f305b4cc9d93cbb567843dd3547c8900fbbcd7e7Eric Ferraiuolo var Assert = Y.Assert,
f305b4cc9d93cbb567843dd3547c8900fbbcd7e7Eric Ferraiuolo suite = new Y.Test.Suite('User Agent String Tests');
f305b4cc9d93cbb567843dd3547c8900fbbcd7e7Eric Ferraiuolo
f305b4cc9d93cbb567843dd3547c8900fbbcd7e7Eric Ferraiuolo var testCase = {
name: 'Node.js',
'test: Node.js': function() {
Assert.areEqual(6, Y.UA.nodejs, 'Failed to get Node.js process version from process object');
Assert.areEqual('Win32', Y.UA.os, 'Failed to get Node.js process platform from process object');
}
};
suite.add(new Y.Test.Case(testCase));
Y.each(Y.UAData, function(info, name) {
testCase = {
name: 'User Agent: ' + name
};
Y.each(info, function(data) {
testCase['test: ' + data.ua] = (function(i) {
return function() {
var ua = YUI.Env.parseUA(i.ua);
Y.each(i.data, function(v, k) {
Y.Assert.areEqual(v, ua[k], 'Key (' + k + ') for ' + i.ua);
});
};
}(data));
});
suite.add(new Y.Test.Case(testCase));
});
Y.Test.Runner.add(suite);
});