@@ -823,6 +823,9 @@ describe('Test lib.js:', function() {
823
823
el . setAttribute ( 'transform' , 'translate(1 2); rotate(20deg)' ) ;
824
824
expect ( Lib . getTranslate ( el ) ) . toEqual ( { x : 1 , y : 2 } ) ;
825
825
826
+ el . setAttribute ( 'transform' , 'rotate(20deg) translate(1 2);' ) ;
827
+ expect ( Lib . getTranslate ( el ) ) . toEqual ( { x : 1 , y : 2 } ) ;
828
+
826
829
el . setAttribute ( 'transform' , 'rotate(20deg)' ) ;
827
830
expect ( Lib . getTranslate ( el ) ) . toEqual ( { x : 0 , y : 0 } ) ;
828
831
} ) ;
@@ -884,6 +887,52 @@ describe('Test lib.js:', function() {
884
887
} ) ;
885
888
} ) ;
886
889
890
+ describe ( 'getScale' , function ( ) {
891
+
892
+ it ( 'should work with regular DOM elements' , function ( ) {
893
+ var el = document . createElement ( 'div' ) ;
894
+
895
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 1 , y : 1 } ) ;
896
+
897
+ el . setAttribute ( 'transform' , 'scale(1.23, 45)' ) ;
898
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 1.23 , y : 45 } ) ;
899
+
900
+ el . setAttribute ( 'transform' , 'scale(123.45)' ) ;
901
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 123.45 , y : 1 } ) ;
902
+
903
+ el . setAttribute ( 'transform' , 'scale(0.1 2)' ) ;
904
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 0.1 , y : 2 } ) ;
905
+
906
+ el . setAttribute ( 'transform' , 'scale(0.1 2); rotate(20deg)' ) ;
907
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 0.1 , y : 2 } ) ;
908
+
909
+ el . setAttribute ( 'transform' , 'rotate(20deg) scale(0.1 2);' ) ;
910
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 0.1 , y : 2 } ) ;
911
+
912
+ el . setAttribute ( 'transform' , 'rotate(20deg)' ) ;
913
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 1 , y : 1 } ) ;
914
+ } ) ;
915
+
916
+ it ( 'should work with d3 elements' , function ( ) {
917
+ var el = d3 . select ( document . createElement ( 'div' ) ) ;
918
+
919
+ el . attr ( 'transform' , 'scale(1.23, 45)' ) ;
920
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 1.23 , y : 45 } ) ;
921
+
922
+ el . attr ( 'transform' , 'scale(123.45)' ) ;
923
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 123.45 , y : 1 } ) ;
924
+
925
+ el . attr ( 'transform' , 'scale(0.1 2)' ) ;
926
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 0.1 , y : 2 } ) ;
927
+
928
+ el . attr ( 'transform' , 'scale(0.1 2); rotate(20)' ) ;
929
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 0.1 , y : 2 } ) ;
930
+
931
+ el . attr ( 'transform' , 'rotate(20)' ) ;
932
+ expect ( Lib . getScale ( el ) ) . toEqual ( { x : 1 , y : 1 } ) ;
933
+ } ) ;
934
+ } ) ;
935
+
887
936
describe ( 'setScale' , function ( ) {
888
937
889
938
it ( 'should work with regular DOM elements' , function ( ) {
0 commit comments