@@ -858,9 +858,6 @@ describe('Test lib.js:', function() {
858
858
Lib . setTranslate ( el , 10 , 20 ) ;
859
859
expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'translate(10, 20)' ) ;
860
860
861
- Lib . setTranslate ( el , 30 , 40 ) ;
862
- expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'translate(30, 40)' ) ;
863
-
864
861
Lib . setTranslate ( el ) ;
865
862
expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'translate(0, 0)' ) ;
866
863
@@ -875,9 +872,6 @@ describe('Test lib.js:', function() {
875
872
Lib . setTranslate ( el , 5 ) ;
876
873
expect ( el . attr ( 'transform' ) ) . toBe ( 'translate(5, 0)' ) ;
877
874
878
- Lib . setTranslate ( el , 10 , 20 ) ;
879
- expect ( el . attr ( 'transform' ) ) . toBe ( 'translate(10, 20)' ) ;
880
-
881
875
Lib . setTranslate ( el , 30 , 40 ) ;
882
876
expect ( el . attr ( 'transform' ) ) . toBe ( 'translate(30, 40)' ) ;
883
877
@@ -890,6 +884,43 @@ describe('Test lib.js:', function() {
890
884
} ) ;
891
885
} ) ;
892
886
887
+ describe ( 'setScale' , function ( ) {
888
+
889
+ it ( 'should work with regular DOM elements' , function ( ) {
890
+ var el = document . createElement ( 'div' ) ;
891
+
892
+ Lib . setScale ( el , 5 ) ;
893
+ expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'scale(5, 1)' ) ;
894
+
895
+ Lib . setScale ( el , 30 , 40 ) ;
896
+ expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'scale(30, 40)' ) ;
897
+
898
+ Lib . setScale ( el ) ;
899
+ expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'scale(1, 1)' ) ;
900
+
901
+ el . setAttribute ( 'transform' , 'scale(1, 1); rotate(30)' ) ;
902
+ Lib . setScale ( el , 30 , 40 ) ;
903
+ expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'rotate(30) scale(30, 40)' ) ;
904
+ } ) ;
905
+
906
+ it ( 'should work with d3 elements' , function ( ) {
907
+ var el = d3 . select ( document . createElement ( 'div' ) ) ;
908
+
909
+ Lib . setScale ( el , 5 ) ;
910
+ expect ( el . attr ( 'transform' ) ) . toBe ( 'scale(5, 1)' ) ;
911
+
912
+ Lib . setScale ( el , 30 , 40 ) ;
913
+ expect ( el . attr ( 'transform' ) ) . toBe ( 'scale(30, 40)' ) ;
914
+
915
+ Lib . setScale ( el ) ;
916
+ expect ( el . attr ( 'transform' ) ) . toBe ( 'scale(1, 1)' ) ;
917
+
918
+ el . attr ( 'transform' , 'scale(0, 0); rotate(30)' ) ;
919
+ Lib . setScale ( el , 30 , 40 ) ;
920
+ expect ( el . attr ( 'transform' ) ) . toBe ( 'rotate(30) scale(30, 40)' ) ;
921
+ } ) ;
922
+ } ) ;
923
+
893
924
describe ( 'pushUnique' , function ( ) {
894
925
895
926
beforeEach ( function ( ) {
0 commit comments