aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/widget
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-01-14 15:52:03 -0500
committerScott González <scott.gonzalez@gmail.com>2011-01-14 15:52:03 -0500
commit25dae411bc7bb0e618db4df062fa2f1c08bfcc77 (patch)
tree66b910c6c697491a4c47b4ebede9000c24f5d454 /tests/unit/widget
parentf711e362cd998f956a21d8e2ef455aca329fd0d7 (diff)
downloadjquery-ui-25dae411bc7bb0e618db4df062fa2f1c08bfcc77.tar.gz
jquery-ui-25dae411bc7bb0e618db4df062fa2f1c08bfcc77.zip
Widget: Added _super() and _superApply() methods. Fixes #6861 - Widget: Add _super() and _superApply() for easy access to parent methods.
Diffstat (limited to 'tests/unit/widget')
-rw-r--r--tests/unit/widget/widget_core.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index c01cd6542..388e078b0 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -228,6 +228,59 @@ test( "re-init", function() {
same( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
});
+test( "._super()", function() {
+ expect( 6 );
+ var instance;
+ $.widget( "ui.testWidget", {
+ method: function( a, b ) {
+ same( this, instance, "this is correct in super widget" );
+ same( a, 5, "parameter passed to super widget" );
+ same( b, 10, "second parameter passed to super widget" );
+ return a + b;
+ }
+ });
+
+ $.widget( "ui.testWidget2", $.ui.testWidget, {
+ method: function( a ) {
+ same( this, instance, "this is correct in widget" );
+ same( a, 5, "parameter passed to widget" );
+ var ret = this._super( "method", a, a*2 );
+ same( ret, 15, "super returned value" );
+ }
+ });
+
+ instance = $( "<div>" ).testWidget2().data( "testWidget2" );
+ instance.method( 5 );
+ delete $.ui.testWidget2;
+});
+
+test( "._superApply()", function() {
+ expect( 7 );
+ var instance;
+ $.widget( "ui.testWidget", {
+ method: function( a, b ) {
+ same( this, instance, "this is correct in super widget" );
+ same( a, 5, "parameter passed to super widget" );
+ same( b, 10, "second parameter passed to super widget" );
+ return a + b;
+ }
+ });
+
+ $.widget( "ui.testWidget2", $.ui.testWidget, {
+ method: function( a, b ) {
+ same( this, instance, "this is correct in widget" );
+ same( a, 5, "parameter passed to widget" );
+ same( b, 10, "second parameter passed to widget" );
+ var ret = this._superApply( "method", arguments );
+ same( ret, 15, "super returned value" );
+ }
+ });
+
+ instance = $( "<div>" ).testWidget2().data( "testWidget2" );
+ instance.method( 5, 10 );
+ delete $.ui.testWidget2;
+});
+
test( ".option() - getter", function() {
$.widget( "ui.testWidget", {
_create: function() {}