aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-02-01 16:59:26 -0500
committerScott González <scott.gonzalez@gmail.com>2012-02-01 16:59:26 -0500
commit8cd4a8330ca79f222e193de585e2746b4ad3500d (patch)
tree17539f7461de70bb018b9ce5353a37300d5b6f75 /tests
parente496cde384d1497993394f04110ef8099d256eee (diff)
downloadjquery-ui-8cd4a8330ca79f222e193de585e2746b4ad3500d.tar.gz
jquery-ui-8cd4a8330ca79f222e193de585e2746b4ad3500d.zip
Widget: Allow redefining a widget after other widgets have inherited from it.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/tabs/tabs_deprecated.js10
-rw-r--r--tests/unit/widget/widget_core.js45
2 files changed, 49 insertions, 6 deletions
diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js
index 1323c774a..d0d13fa84 100644
--- a/tests/unit/tabs/tabs_deprecated.js
+++ b/tests/unit/tabs/tabs_deprecated.js
@@ -281,7 +281,7 @@ test( "enable", function() {
var element = $( "#tabs1" ).tabs({
disabled: [ 0, 1 ],
- enable: function ( event, ui ) {
+ enable: function( event, ui ) {
equals( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
equals( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
equals( ui.index, 1, "ui.index" );
@@ -296,10 +296,10 @@ test( "disable", function() {
expect( 3 );
var element = $( "#tabs1" ).tabs({
- disable: function ( event, ui ) {
- equals( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
- equals( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
- equals( ui.index, 1, "ui.index" );
+ disable: function( event, ui ) {
+ equals( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
+ equals( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
+ equals( ui.index, 1, "ui.index" );
}
});
element.tabs( "disable", 1 );
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index df83abe91..86fa658aa 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -1050,11 +1050,54 @@ test( "redefine", function() {
}
});
- var instance = new $.ui.testWidget();
+ var instance = new $.ui.testWidget({});
instance.method( "foo" );
equal( $.ui.testWidget.foo, "bar", "static properties remain" );
});
+test( "redefine deep prototype chain", function() {
+ expect( 8 );
+ $.widget( "ui.testWidget", {
+ method: function( str ) {
+ strictEqual( this, instance, "original invoked with correct this" );
+ equal( str, "level 4", "original invoked with correct parameter" );
+ }
+ });
+ $.widget( "ui.testWidget2", $.ui.testWidget, {
+ method: function( str ) {
+ strictEqual( this, instance, "testWidget2 invoked with correct this" );
+ equal( str, "level 2", "testWidget2 invoked with correct parameter" );
+ this._super( "level 3" );
+ }
+ });
+ $.widget( "ui.testWidget3", $.ui.testWidget2, {
+ method: function( str ) {
+ strictEqual( this, instance, "testWidget3 invoked with correct this" );
+ equal( str, "level 1", "testWidget3 invoked with correct parameter" );
+ this._super( "level 2" );
+ }
+ });
+ // redefine testWidget after other widgets have inherited from it
+ // this tests whether the inheriting widgets get updated prototype chains
+ $.widget( "ui.testWidget", $.ui.testWidget, {
+ method: function( str ) {
+ strictEqual( this, instance, "new invoked with correct this" );
+ equal( str, "level 3", "new invoked with correct parameter" );
+ this._super( "level 4" );
+ }
+ });
+ // redefine testWidget3 after it has been automatically redefined
+ // this tests whether we properly handle _super() when the topmost prototype
+ // doesn't have the method defined
+ $.widget( "ui.testWidget3", $.ui.testWidget3, {} );
+
+ var instance = new $.ui.testWidget3({});
+ instance.method( "level 1" );
+
+ delete $.ui.testWidget3;
+ delete $.ui.testWidget2;
+});
+
asyncTest( "_delay", function() {
expect( 6 );
var order = 0,