2009-02-02 06:46:56 +00:00
|
|
|
function testWidgetDefaults(widget, defaults) {
|
2009-04-17 21:28:37 +00:00
|
|
|
var pluginDefaults = $.extend({},
|
2010-01-07 03:19:50 +00:00
|
|
|
$.ui[widget].prototype.options
|
2009-04-17 21:28:37 +00:00
|
|
|
);
|
|
|
|
|
2010-01-07 03:19:50 +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) {
|
2009-09-15 08:26:59 +00:00
|
|
|
if ($.isFunction(val)) {
|
2010-01-07 03:19:50 +00:00
|
|
|
ok(val !== undefined, key);
|
2009-09-15 08:26:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-04-17 21:28:37 +00:00
|
|
|
same(pluginDefaults[key], val, key);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// ensure that all defaults were tested
|
|
|
|
test('tested defaults', function() {
|
2009-09-15 08:26:59 +00:00
|
|
|
$.each(pluginDefaults, function(key, val) {
|
2009-04-17 21:28:37 +00:00
|
|
|
ok(key in defaults, key);
|
|
|
|
});
|
|
|
|
});
|
2009-02-02 06:46:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testWidgetOverrides(widget) {
|
2009-04-17 21:28:37 +00:00
|
|
|
test('$.widget overrides', function() {
|
2010-01-07 03:19:50 +00:00
|
|
|
$.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);
|
|
|
|
});
|
|
|
|
});
|
2009-02-02 06:46:56 +00:00
|
|
|
}
|
2010-01-07 03:19:50 +00:00
|
|
|
|
2009-02-02 06:46:56 +00:00
|
|
|
function commonWidgetTests(widget, settings) {
|
|
|
|
module(widget + ": common widget");
|
|
|
|
|
2009-04-17 21:28:37 +00:00
|
|
|
testWidgetDefaults(widget, settings.defaults);
|
|
|
|
testWidgetOverrides(widget);
|
2009-02-02 06:46:56 +00:00
|
|
|
}
|