@@ -34,7 +34,7 @@ test( "element normalization", function() {
3434 } ;
3535 $ . ui . testWidget ( ) ;
3636
37- $ . ui . testWidget . prototype . defaultElement = "<span data-test='pass'>" ;
37+ $ . ui . testWidget . prototype . defaultElement = "<span data-test='pass'></span> " ;
3838 $ . ui . testWidget . prototype . _create = function ( ) {
3939 ok ( this . element . is ( "span[data-test=pass]" ) , "generated span with properties" ) ;
4040 same ( this . element . data ( "testWidget" ) , this , "instace stored in .data()" ) ;
@@ -224,12 +224,12 @@ test( "._getCreateOptions()", function() {
224224 options : {
225225 option1 : "valuex" ,
226226 option2 : "valuex" ,
227- option3 : "value3" ,
227+ option3 : "value3"
228228 } ,
229229 _getCreateOptions : function ( ) {
230230 return {
231231 option1 : "override1" ,
232- option2 : "overideX" ,
232+ option2 : "overideX"
233233 } ;
234234 } ,
235235 _create : function ( ) {
@@ -274,55 +274,75 @@ test( "re-init", function() {
274274} ) ;
275275
276276test ( "._super()" , function ( ) {
277- expect ( 6 ) ;
277+ expect ( 9 ) ;
278278 var instance ;
279279 $ . widget ( "ui.testWidget" , {
280280 method : function ( a , b ) {
281- same ( this , instance , "this is correct in super widget " ) ;
282- same ( a , 5 , "parameter passed to super widget " ) ;
283- same ( b , 10 , "second parameter passed to super widget " ) ;
281+ same ( this , instance , "this is correct in testWidget " ) ;
282+ same ( a , 5 , "parameter passed to testWidget " ) ;
283+ same ( b , 20 , "second parameter passed to testWidget " ) ;
284284 return a + b ;
285285 }
286286 } ) ;
287287
288288 $ . widget ( "ui.testWidget2" , $ . ui . testWidget , {
289+ method : function ( a , b ) {
290+ same ( this , instance , "this is correct in testWidget2" ) ;
291+ same ( a , 5 , "parameter passed to testWidget2" ) ;
292+ same ( b , 10 , "parameter passed to testWidget2" ) ;
293+ return this . _super ( "method" , a , b * 2 ) ;
294+ }
295+ } ) ;
296+
297+ $ . widget ( "ui.testWidget3" , $ . ui . testWidget2 , {
289298 method : function ( a ) {
290- same ( this , instance , "this is correct in widget " ) ;
291- same ( a , 5 , "parameter passed to widget " ) ;
299+ same ( this , instance , "this is correct in testWidget3 " ) ;
300+ same ( a , 5 , "parameter passed to testWidget3 " ) ;
292301 var ret = this . _super ( "method" , a , a * 2 ) ;
293- same ( ret , 15 , "super returned value" ) ;
302+ same ( ret , 25 , "super returned value" ) ;
294303 }
295304 } ) ;
296305
297- instance = $ ( "<div>" ) . testWidget2 ( ) . data ( "testWidget2 " ) ;
306+ instance = $ ( "<div>" ) . testWidget3 ( ) . data ( "testWidget3 " ) ;
298307 instance . method ( 5 ) ;
308+ delete $ . ui . testWidget3 ;
299309 delete $ . ui . testWidget2 ;
300310} ) ;
301311
302312test ( "._superApply()" , function ( ) {
303- expect ( 7 ) ;
313+ expect ( 10 ) ;
304314 var instance ;
305315 $ . widget ( "ui.testWidget" , {
306316 method : function ( a , b ) {
307- same ( this , instance , "this is correct in super widget " ) ;
308- same ( a , 5 , "parameter passed to super widget " ) ;
309- same ( b , 10 , "second parameter passed to super widget " ) ;
317+ same ( this , instance , "this is correct in testWidget " ) ;
318+ same ( a , 5 , "parameter passed to testWidget " ) ;
319+ same ( b , 10 , "second parameter passed to testWidget " ) ;
310320 return a + b ;
311321 }
312322 } ) ;
313323
314324 $ . widget ( "ui.testWidget2" , $ . ui . testWidget , {
315325 method : function ( a , b ) {
316- same ( this , instance , "this is correct in widget" ) ;
317- same ( a , 5 , "parameter passed to widget" ) ;
318- same ( b , 10 , "second parameter passed to widget" ) ;
326+ same ( this , instance , "this is correct in testWidget2" ) ;
327+ same ( a , 5 , "parameter passed to testWidget2" ) ;
328+ same ( b , 10 , "second parameter passed to testWidget2" ) ;
329+ return this . _superApply ( "method" , arguments ) ;
330+ }
331+ } ) ;
332+
333+ $ . widget ( "ui.testWidget3" , $ . ui . testWidget2 , {
334+ method : function ( a , b ) {
335+ same ( this , instance , "this is correct in testWidget3" ) ;
336+ same ( a , 5 , "parameter passed to testWidget3" ) ;
337+ same ( b , 10 , "second parameter passed to testWidget3" ) ;
319338 var ret = this . _superApply ( "method" , arguments ) ;
320339 same ( ret , 15 , "super returned value" ) ;
321340 }
322341 } ) ;
323342
324- instance = $ ( "<div>" ) . testWidget2 ( ) . data ( "testWidget2 " ) ;
343+ instance = $ ( "<div>" ) . testWidget3 ( ) . data ( "testWidget3 " ) ;
325344 instance . method ( 5 , 10 ) ;
345+ delete $ . ui . testWidget3 ;
326346 delete $ . ui . testWidget2 ;
327347} ) ;
328348
@@ -829,7 +849,7 @@ test( "redefine", function() {
829849 equal ( str , "bar" , "original invoked with correct parameter" ) ;
830850 }
831851 } ) ;
832- var ctor = $ . ui . testWidget ;
852+ $ . ui . testWidget . foo = "bar" ;
833853 $ . widget ( "ui.testWidget" , $ . ui . testWidget , {
834854 method : function ( str ) {
835855 equal ( str , "foo" , "new invoked with correct parameter" ) ;
@@ -839,7 +859,7 @@ test( "redefine", function() {
839859
840860 var instance = new $ . ui . testWidget ( ) ;
841861 instance . method ( "foo" ) ;
842- equal ( $ . ui . testWidget , ctor , "constructor did not change " ) ;
862+ equal ( $ . ui . testWidget . foo , "bar" , "static properties remain " ) ;
843863} ) ;
844864
845865} ( jQuery ) ) ;
0 commit comments