@@ -502,12 +502,17 @@ new Test.Unit.Runner({
502
502
503
503
testElementIdentify : function ( ) {
504
504
var parent = $ ( 'identification' ) ;
505
- this . assertEqual ( parent . down ( ) . identify ( ) , 'predefined_id' ) ;
506
- this . assert ( parent . down ( 1 ) . identify ( ) . startsWith ( 'anonymous_element_' ) ) ;
507
- this . assert ( parent . down ( 2 ) . identify ( ) . startsWith ( 'anonymous_element_' ) ) ;
508
- this . assert ( parent . down ( 3 ) . identify ( ) . startsWith ( 'anonymous_element_' ) ) ;
509
-
510
- this . assert ( parent . down ( 3 ) . id !== parent . down ( 2 ) . id ) ;
505
+ this . assertEqual ( parent . down ( ) . identify ( ) , 'predefined_id' ,
506
+ "identify should preserve the IDs of elements that already have them" ) ;
507
+ this . assert ( parent . down ( 1 ) . identify ( ) . startsWith ( 'anonymous_element_' ) ,
508
+ "should have #anonymous_element_1" ) ;
509
+ this . assert ( parent . down ( 2 ) . identify ( ) . startsWith ( 'anonymous_element_' ) ,
510
+ "should have #anonymous_element_2" ) ;
511
+ this . assert ( parent . down ( 3 ) . identify ( ) . startsWith ( 'anonymous_element_' ) ,
512
+ "should have #anonymous_element_3" ) ;
513
+
514
+ this . assert ( parent . down ( 3 ) . id !== parent . down ( 2 ) . id ,
515
+ "should not assign duplicate IDs" ) ;
511
516
} ,
512
517
513
518
testElementClassNameMethod : function ( ) {
@@ -760,10 +765,12 @@ new Test.Unit.Runner({
760
765
} ,
761
766
762
767
testDescendantOf : function ( ) {
763
- this . assert ( $ ( 'child' ) . descendantOf ( 'ancestor' ) ) ;
764
- this . assert ( $ ( 'child' ) . descendantOf ( $ ( 'ancestor' ) ) ) ;
765
-
766
- this . assert ( ! $ ( 'ancestor' ) . descendantOf ( $ ( 'child' ) ) ) ;
768
+ this . assert ( $ ( 'child' ) . descendantOf ( 'ancestor' ) ,
769
+ '#child should be descendant of #ancestor' ) ;
770
+ this . assert ( $ ( 'child' ) . descendantOf ( $ ( 'ancestor' ) ) ,
771
+ '#child should be descendant of #ancestor' ) ;
772
+ this . assert ( ! $ ( 'ancestor' ) . descendantOf ( $ ( 'child' ) ) ,
773
+ '#ancestor should not be descendant of child' ) ;
767
774
768
775
this . assert ( $ ( 'great-grand-child' ) . descendantOf ( 'ancestor' ) , 'great-grand-child < ancestor' ) ;
769
776
this . assert ( $ ( 'grand-child' ) . descendantOf ( 'ancestor' ) , 'grand-child < ancestor' ) ;
@@ -783,18 +790,23 @@ new Test.Unit.Runner({
783
790
this . assert ( ! $ ( 'great-grand-child' ) . descendantOf ( 'not-in-the-family' ) , 'great-grand-child < not-in-the-family' ) ;
784
791
this . assert ( ! $ ( 'child' ) . descendantOf ( 'not-in-the-family' ) , 'child < not-in-the-family' ) ;
785
792
786
- this . assert ( ! $ ( document . body ) . descendantOf ( 'great-grand-child' ) ) ;
793
+ this . assert ( ! $ ( document . body ) . descendantOf ( 'great-grand-child' ) ,
794
+ 'BODY should not be descendant of anything within it' ) ;
787
795
788
796
// dynamically-created elements
789
797
$ ( 'ancestor' ) . insert ( new Element ( 'div' , { id : 'weird-uncle' } ) ) ;
790
- this . assert ( $ ( 'weird-uncle' ) . descendantOf ( 'ancestor' ) ) ;
798
+ this . assert ( $ ( 'weird-uncle' ) . descendantOf ( 'ancestor' ) ,
799
+ 'dynamically-created element should work properly' ) ;
791
800
792
801
$ ( document . body ) . insert ( new Element ( 'div' , { id : 'impostor' } ) ) ;
793
- this . assert ( ! $ ( 'impostor' ) . descendantOf ( 'ancestor' ) ) ;
802
+ this . assert ( ! $ ( 'impostor' ) . descendantOf ( 'ancestor' ) ,
803
+ 'elements inserted elsewhere in the DOM tree should not be descendants' ) ;
794
804
795
805
// test descendantOf document
796
- this . assert ( $ ( document . body ) . descendantOf ( document ) ) ;
797
- this . assert ( $ ( document . documentElement ) . descendantOf ( document ) ) ;
806
+ this . assert ( $ ( document . body ) . descendantOf ( document ) ,
807
+ 'descendantOf(document) should behave predictably' ) ;
808
+ this . assert ( $ ( document . documentElement ) . descendantOf ( document ) ,
809
+ 'descendantOf(document) should behave predictably' ) ;
798
810
} ,
799
811
800
812
testChildOf : function ( ) {
@@ -829,11 +841,9 @@ new Test.Unit.Runner({
829
841
$ ( 'style_test_3' ) . setStyle ( { opacity : 0.5 } ) ;
830
842
this . assertEqual ( 0.5 , $ ( 'style_test_3' ) . getStyle ( 'opacity' ) ) ;
831
843
832
- window . debug = true ;
833
844
$ ( 'style_test_3' ) . setStyle ( { opacity : '' } ) ;
834
845
this . assertEqual ( 1 , $ ( 'style_test_3' ) . getStyle ( 'opacity' ) ,
835
846
'#style_test_3 opacity should be 1' ) ;
836
- window . debug = false ;
837
847
838
848
$ ( 'style_test_3' ) . setStyle ( { opacity : 0 } ) ;
839
849
this . assertEqual ( 0 , $ ( 'style_test_3' ) . getStyle ( 'opacity' ) ,
@@ -869,15 +879,18 @@ new Test.Unit.Runner({
869
879
} ,
870
880
871
881
testElementSetOpacity : function ( ) {
872
- [ 0 , 0.1 , 0.5 , 0.999 ] . each ( function ( opacity ) {
882
+ [ 0 , 0.1 , 0.5 , 0.999 ] . each ( function ( opacity ) {
873
883
$ ( 'style_test_3' ) . setOpacity ( opacity ) ;
874
884
875
885
// b/c of rounding issues on IE special case
876
886
var realOpacity = $ ( 'style_test_3' ) . getStyle ( 'opacity' ) ;
877
887
878
888
// opera rounds off to two significant digits, so we check for a
879
889
// ballpark figure
880
- this . assert ( ( Number ( realOpacity ) - opacity ) <= 0.002 , 'setting opacity to ' + opacity ) ;
890
+ this . assert (
891
+ ( Number ( realOpacity ) - opacity ) <= 0.002 ,
892
+ 'setting opacity to ' + opacity + ' (actual: ' + realOpacity + ')'
893
+ ) ;
881
894
} , this ) ;
882
895
883
896
this . assertEqual ( 0 ,
0 commit comments