diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-02-03 16:37:17 -0500 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-02-03 16:37:17 -0500 |
commit | ee88a562433e75a0dd500ed7c71376d279eaacdf (patch) | |
tree | add7d9669cf4d41a04005b04c312749b867d5b38 /tests | |
parent | ed4903370090c5e81a5be7a9e23f351fc1b062a6 (diff) | |
download | jquery-ui-ee88a562433e75a0dd500ed7c71376d279eaacdf.tar.gz jquery-ui-ee88a562433e75a0dd500ed7c71376d279eaacdf.zip |
Widget: Added ability to use $.widget() to create extensions. Fixes #6937 - Widget: Allow redefining a widget to create extensions.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/widget/widget_core.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 6f4930621..186c407ed 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -821,4 +821,25 @@ test( "auto-destroy - .detach()", function() { $( "#widget" ).testWidget().detach(); }); +test( "redefine", function() { + expect( 4 ); + $.widget( "ui.testWidget", { + method: function( str ) { + strictEqual( this, instance, "original invoked with correct this" ); + equal( str, "bar", "original invoked with correct parameter" ); + } + }); + var ctor = $.ui.testWidget; + $.widget( "ui.testWidget", $.ui.testWidget, { + method: function( str ) { + equal( str, "foo", "new invoked with correct parameter" ); + this._super( "method", "bar" ); + } + }); + + var instance = new $.ui.testWidget(); + instance.method( "foo" ); + equal( $.ui.testWidget, ctor, "constructor did not change" ); +}); + }( jQuery ) ); |