aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/testsuite.js
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-01-24 19:20:09 -0500
committerScott González <scott.gonzalez@gmail.com>2011-01-24 19:20:09 -0500
commit5ed1046a4ac271a1f20cc1f19aa50bec15cd9704 (patch)
tree029e568f6d417e884a8e9e2db6a346b1430a461c /tests/unit/testsuite.js
parentecc0ef53dee0eb3ce432348762abf4550aad8b36 (diff)
downloadjquery-ui-5ed1046a4ac271a1f20cc1f19aa50bec15cd9704.tar.gz
jquery-ui-5ed1046a4ac271a1f20cc1f19aa50bec15cd9704.zip
Accordion tests: Cleanup.
Diffstat (limited to 'tests/unit/testsuite.js')
-rw-r--r--tests/unit/testsuite.js74
1 files changed, 51 insertions, 23 deletions
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index d152f84cd..23819d0e4 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -1,39 +1,67 @@
-function testWidgetDefaults(widget, defaults) {
- var pluginDefaults = $.extend({},
- $.ui[widget].prototype.options
- );
-
+(function() {
+
+function testWidgetDefaults( widget, defaults ) {
+ var pluginDefaults = $.ui[ widget ].prototype.options;
+
// ensure that all defaults have the correct value
- test('defined defaults', function() {
- $.each(defaults, function(key, val) {
- if ($.isFunction(val)) {
- ok(val !== undefined, key);
+ test( "defined defaults", function() {
+ $.each( defaults, function( key, val ) {
+ if ( $.isFunction( val ) ) {
+ ok( $.isFunction( pluginDefaults[ key ] ), key );
return;
}
- same(pluginDefaults[key], val, key);
+ same( pluginDefaults[ key ], val, key );
});
});
-
+
// ensure that all defaults were tested
- test('tested defaults', function() {
- $.each(pluginDefaults, function(key, val) {
- ok(key in defaults, key);
+ test( "tested defaults", function() {
+ $.each( pluginDefaults, function( key, val ) {
+ ok( key in defaults, key );
});
});
}
-function testWidgetOverrides(widget) {
- test('$.widget overrides', function() {
- $.each(['_widgetInit', 'option', '_trigger'], function(i, method) {
- ok($.Widget.prototype[method] == $.ui[widget].prototype[method],
- 'should not override ' + method);
+var privateMethods = [
+ "_createWidget",
+ "_super",
+ "_superApply",
+ "destroy",
+ "option",
+ "enable",
+ "disable",
+ "_trigger"
+];
+
+function testWidgetOverrides( widget ) {
+ test( "$.widget overrides", function() {
+ $.each( privateMethods, function( i, method ) {
+ strictEqual( $.ui[ widget ].prototype[ method ],
+ $.Widget.prototype[ method ], "should not override " + method );
});
});
}
-function commonWidgetTests(widget, settings) {
- module(widget + ": common widget");
+function testBasicUsage( widget ) {
+ test( "basic usage", function() {
+ var defaultElement = $.ui[ widget ].prototype.defaultElement;
+ $( defaultElement ).appendTo( "body" )[ widget ]().remove();
+ ok( true, "initialized on element" );
+
+ $( defaultElement ).accordion().remove();
+ ok( true, "initialized on disconnected DOMElement - never connected" );
- testWidgetDefaults(widget, settings.defaults);
- testWidgetOverrides(widget);
+ $( defaultElement ).appendTo( "body" ).remove().accordion().remove();
+ ok( true, "initialized on disconnected DOMElement - removed" );
+ });
}
+
+window.commonWidgetTests = function( widget, settings ) {
+ module( widget + ": common widget" );
+
+ testWidgetDefaults( widget, settings.defaults );
+ testWidgetOverrides( widget );
+ testBasicUsage( widget );
+};
+
+}());