@@ -34,7 +34,7 @@ test( "element normalization", function() {
34
34
} ;
35
35
$ . ui . testWidget ( ) ;
36
36
37
- $ . ui . testWidget . prototype . defaultElement = "<span data-test='pass'>" ;
37
+ $ . ui . testWidget . prototype . defaultElement = "<span data-test='pass'></span> " ;
38
38
$ . ui . testWidget . prototype . _create = function ( ) {
39
39
ok ( this . element . is ( "span[data-test=pass]" ) , "generated span with properties" ) ;
40
40
same ( this . element . data ( "testWidget" ) , this , "instace stored in .data()" ) ;
@@ -224,12 +224,12 @@ test( "._getCreateOptions()", function() {
224
224
options : {
225
225
option1 : "valuex" ,
226
226
option2 : "valuex" ,
227
- option3 : "value3" ,
227
+ option3 : "value3"
228
228
} ,
229
229
_getCreateOptions : function ( ) {
230
230
return {
231
231
option1 : "override1" ,
232
- option2 : "overideX" ,
232
+ option2 : "overideX"
233
233
} ;
234
234
} ,
235
235
_create : function ( ) {
@@ -274,55 +274,75 @@ test( "re-init", function() {
274
274
} ) ;
275
275
276
276
test ( "._super()" , function ( ) {
277
- expect ( 6 ) ;
277
+ expect ( 9 ) ;
278
278
var instance ;
279
279
$ . widget ( "ui.testWidget" , {
280
280
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 " ) ;
284
284
return a + b ;
285
285
}
286
286
} ) ;
287
287
288
288
$ . 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 , {
289
298
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 " ) ;
292
301
var ret = this . _super ( "method" , a , a * 2 ) ;
293
- same ( ret , 15 , "super returned value" ) ;
302
+ same ( ret , 25 , "super returned value" ) ;
294
303
}
295
304
} ) ;
296
305
297
- instance = $ ( "<div>" ) . testWidget2 ( ) . data ( "testWidget2 " ) ;
306
+ instance = $ ( "<div>" ) . testWidget3 ( ) . data ( "testWidget3 " ) ;
298
307
instance . method ( 5 ) ;
308
+ delete $ . ui . testWidget3 ;
299
309
delete $ . ui . testWidget2 ;
300
310
} ) ;
301
311
302
312
test ( "._superApply()" , function ( ) {
303
- expect ( 7 ) ;
313
+ expect ( 10 ) ;
304
314
var instance ;
305
315
$ . widget ( "ui.testWidget" , {
306
316
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 " ) ;
310
320
return a + b ;
311
321
}
312
322
} ) ;
313
323
314
324
$ . widget ( "ui.testWidget2" , $ . ui . testWidget , {
315
325
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" ) ;
319
338
var ret = this . _superApply ( "method" , arguments ) ;
320
339
same ( ret , 15 , "super returned value" ) ;
321
340
}
322
341
} ) ;
323
342
324
- instance = $ ( "<div>" ) . testWidget2 ( ) . data ( "testWidget2 " ) ;
343
+ instance = $ ( "<div>" ) . testWidget3 ( ) . data ( "testWidget3 " ) ;
325
344
instance . method ( 5 , 10 ) ;
345
+ delete $ . ui . testWidget3 ;
326
346
delete $ . ui . testWidget2 ;
327
347
} ) ;
328
348
@@ -829,7 +849,7 @@ test( "redefine", function() {
829
849
equal ( str , "bar" , "original invoked with correct parameter" ) ;
830
850
}
831
851
} ) ;
832
- var ctor = $ . ui . testWidget ;
852
+ $ . ui . testWidget . foo = "bar" ;
833
853
$ . widget ( "ui.testWidget" , $ . ui . testWidget , {
834
854
method : function ( str ) {
835
855
equal ( str , "foo" , "new invoked with correct parameter" ) ;
@@ -839,7 +859,7 @@ test( "redefine", function() {
839
859
840
860
var instance = new $ . ui . testWidget ( ) ;
841
861
instance . method ( "foo" ) ;
842
- equal ( $ . ui . testWidget , ctor , "constructor did not change " ) ;
862
+ equal ( $ . ui . testWidget . foo , "bar" , "static properties remain " ) ;
843
863
} ) ;
844
864
845
865
} ( jQuery ) ) ;
0 commit comments