aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/testsuite.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2010-01-07 03:19:50 +0000
committerScott González <scott.gonzalez@gmail.com>2010-01-07 03:19:50 +0000
commit90fb45dffafc2e891b1ebca948ad33e6b94de112 (patch)
tree6bd09ea116ef2cdd86ec0fa70bf740617f67d441 /tests/unit/testsuite.js
parent975b02a82cdff29fd8469bfe4324472c2ae3f954 (diff)
downloadjquery-ui-90fb45dffafc2e891b1ebca948ad33e6b94de112.tar.gz
jquery-ui-90fb45dffafc2e891b1ebca948ad33e6b94de112.zip
Merged in /branches/dev r3251:3620 (excluding autocomplete, modal, tooltip, menu; including menu static tests).
Diffstat (limited to 'tests/unit/testsuite.js')
-rw-r--r--tests/unit/testsuite.js64
1 files changed, 6 insertions, 58 deletions
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index 345a5a106..81390d59b 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -3,15 +3,14 @@ var hasDuplicate = false;
function testWidgetDefaults(widget, defaults) {
var pluginDefaults = $.extend({},
- $.widget.defaults,
- $.ui[widget].defaults
+ $.ui[widget].prototype.options
);
- // ensure that all defualts have the correct value
+ // ensure that all defaults have the correct value
test('defined defaults', function() {
$.each(defaults, function(key, val) {
if ($.isFunction(val)) {
- ok(val !== undefined);
+ ok(val !== undefined, key);
return;
}
same(pluginDefaults[key], val, key);
@@ -24,72 +23,21 @@ function testWidgetDefaults(widget, defaults) {
ok(key in defaults, key);
});
});
-
- // defaults after init
- test('defaults on init', function() {
- var el = $('<div/>')[widget](),
- instance = el.data(widget);
-
- $.each(defaults, function(key, val) {
- if ($.isFunction(val)) {
- ok(val !== undefined);
- return;
- }
- same(instance.options[key], val, key);
- });
- el.remove();
- });
-}
-
-function testSettingOptions(widget, options) {
- test('option values', function() {
- var el = $('<div/>')[widget](),
- instance = el.data(widget);
-
- $.each(options, function(i, option) {
- $.each({
- 'null': null,
- 'false': false,
- 'true': true,
- zero: 0,
- number: 1,
- 'empty string': '',
- string: 'string',
- 'empty array': [],
- array: ['array'],
- 'empty object': {},
- object: {obj: 'ect'},
- date: new Date(),
- regexp: /regexp/,
- 'function': function() {}
- }, function(type, val) {
- el[widget]('option', option, val);
- same(instance.options[option], val, option + ': ' + type);
- });
- });
-
- el.remove();
- });
}
function testWidgetOverrides(widget) {
test('$.widget overrides', function() {
- $.each(['option', '_getData', '_trigger'], function(i, method) {
- ok($.widget.prototype[method] == $.ui[widget].prototype[method],
+ $.each(['_widgetInit', 'option', '_trigger'], function(i, method) {
+ ok($.Widget.prototype[method] == $.ui[widget].prototype[method],
'should not override ' + method);
});
});
}
+
function commonWidgetTests(widget, settings) {
- var options = [];
- $.each(settings.defaults, function(option) {
- options.push(option);
- });
-
module(widget + ": common widget");
testWidgetDefaults(widget, settings.defaults);
- testSettingOptions(widget, options);
testWidgetOverrides(widget);
}