jquery-ui/tests/unit/testsuite.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

function testWidgetDefaults(widget, defaults) {
2009-04-17 21:28:37 +00:00
var pluginDefaults = $.extend({},
$.ui[widget].prototype.options
2009-04-17 21:28:37 +00:00
);
// ensure that all defaults have the correct value
2009-04-17 21:28:37 +00:00
test('defined defaults', function() {
$.each(defaults, function(key, val) {
if ($.isFunction(val)) {
ok(val !== undefined, key);
return;
}
2009-04-17 21:28:37 +00:00
same(pluginDefaults[key], val, key);
});
});
// ensure that all defaults were tested
test('tested defaults', function() {
$.each(pluginDefaults, function(key, val) {
2009-04-17 21:28:37 +00:00
ok(key in defaults, key);
});
});
}
function testWidgetOverrides(widget) {
2009-04-17 21:28:37 +00:00
test('$.widget overrides', function() {
$.each(['_widgetInit', 'option', '_trigger'], function(i, method) {
ok($.Widget.prototype[method] == $.ui[widget].prototype[method],
2009-04-17 21:28:37 +00:00
'should not override ' + method);
});
});
}
function commonWidgetTests(widget, settings) {
module(widget + ": common widget");
2009-04-17 21:28:37 +00:00
testWidgetDefaults(widget, settings.defaults);
testWidgetOverrides(widget);
}
// load testswarm agent
(function() {
var url = window.location.search;
url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
if ( !url || url.indexOf("http") !== 0 ) {
return;
}
document.write("<scr" + "ipt src='http://testswarm.com/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
})();