@@ -927,68 +927,56 @@ test( "._trigger() - instance as element", function() {
927
927
instance . testEvent ( ) ;
928
928
} ) ;
929
929
930
- test ( "auto-destroy - .remove()" , function ( ) {
931
- expect ( 1 ) ;
932
- $ . widget ( "ui.testWidget" , {
933
- _create : function ( ) { } ,
934
- destroy : function ( ) {
935
- ok ( true , "destroyed from .remove()" ) ;
936
- }
937
- } ) ;
938
- $ ( "#widget" ) . testWidget ( ) . remove ( ) ;
939
- } ) ;
930
+ ( function ( ) {
931
+ function shouldDestroy ( expected , callback ) {
932
+ expect ( 1 ) ;
933
+ var destroyed = false ;
934
+ $ . widget ( "ui.testWidget" , {
935
+ _create : function ( ) { } ,
936
+ destroy : function ( ) {
937
+ destroyed = true ;
938
+ }
939
+ } ) ;
940
+ callback ( ) ;
941
+ equal ( destroyed , expected ) ;
942
+ }
940
943
941
- test ( "auto-destroy - .remove() on parent" , function ( ) {
942
- expect ( 1 ) ;
943
- $ . widget ( "ui.testWidget" , {
944
- _create : function ( ) { } ,
945
- destroy : function ( ) {
946
- ok ( true , "destroyed from .remove() on parent" ) ;
947
- }
944
+ test ( "auto-destroy - .remove()" , function ( ) {
945
+ shouldDestroy ( true , function ( ) {
946
+ $ ( "#widget" ) . testWidget ( ) . remove ( ) ;
947
+ } ) ;
948
948
} ) ;
949
- $ ( "#widget" ) . testWidget ( ) . parent ( ) . remove ( ) ;
950
- } ) ;
951
-
952
- test ( "auto-destroy - .remove() on child" , function ( ) {
953
- $ . widget ( "ui.testWidget" , {
954
- _create : function ( ) { } ,
955
- destroy : function ( ) {
956
- ok ( false , "destroyed from .remove() on child" ) ;
957
- }
949
+
950
+ test ( "auto-destroy - .remove() on parent" , function ( ) {
951
+ shouldDestroy ( true , function ( ) {
952
+ $ ( "#widget" ) . testWidget ( ) . parent ( ) . remove ( ) ;
953
+ } ) ;
958
954
} ) ;
959
- $ ( "#widget" ) . testWidget ( ) . children ( ) . remove ( ) ;
960
- } ) ;
961
-
962
- test ( "auto-destroy - .empty()" , function ( ) {
963
- $ . widget ( "ui.testWidget" , {
964
- _create : function ( ) { } ,
965
- destroy : function ( ) {
966
- ok ( false , "destroyed from .empty()" ) ;
967
- }
955
+
956
+ test ( "auto-destroy - .remove() on child" , function ( ) {
957
+ shouldDestroy ( false , function ( ) {
958
+ $ ( "#widget" ) . testWidget ( ) . children ( ) . remove ( ) ;
959
+ } ) ;
968
960
} ) ;
969
- $ ( "#widget" ) . testWidget ( ) . empty ( ) ;
970
- } ) ;
971
-
972
- test ( "auto-destroy - .empty() on parent" , function ( ) {
973
- expect ( 1 ) ;
974
- $ . widget ( "ui.testWidget" , {
975
- _create : function ( ) { } ,
976
- destroy : function ( ) {
977
- ok ( true , "destroyed from .empty() on parent" ) ;
978
- }
961
+
962
+ test ( "auto-destroy - .empty()" , function ( ) {
963
+ shouldDestroy ( false , function ( ) {
964
+ $ ( "#widget" ) . testWidget ( ) . empty ( ) ;
965
+ } ) ;
979
966
} ) ;
980
- $ ( "#widget" ) . testWidget ( ) . parent ( ) . empty ( ) ;
981
- } ) ;
982
-
983
- test ( "auto-destroy - .detach()" , function ( ) {
984
- $ . widget ( "ui.testWidget" , {
985
- _create : function ( ) { } ,
986
- destroy : function ( ) {
987
- ok ( false , "destroyed from .detach()" ) ;
988
- }
967
+
968
+ test ( "auto-destroy - .empty() on parent" , function ( ) {
969
+ shouldDestroy ( true , function ( ) {
970
+ $ ( "#widget" ) . testWidget ( ) . parent ( ) . empty ( ) ;
971
+ } ) ;
989
972
} ) ;
990
- $ ( "#widget" ) . testWidget ( ) . detach ( ) ;
991
- } ) ;
973
+
974
+ test ( "auto-destroy - .detach()" , function ( ) {
975
+ shouldDestroy ( false , function ( ) {
976
+ $ ( "#widget" ) . testWidget ( ) . detach ( ) ;
977
+ } ) ;
978
+ } ) ;
979
+ } ( ) ) ;
992
980
993
981
test ( "redefine" , function ( ) {
994
982
expect ( 4 ) ;
0 commit comments