@@ -823,6 +823,9 @@ describe('Test lib.js:', function() {
823823 el . setAttribute ( 'transform' , 'translate(1 2); rotate(20deg)' ) ;
824824 expect ( Lib . getTranslate ( el ) ) . toEqual ( { x : 1 , y : 2 } ) ;
825825
826+ el . setAttribute ( 'transform' , 'rotate(20deg) translate(1 2);' ) ;
827+ expect ( Lib . getTranslate ( el ) ) . toEqual ( { x : 1 , y : 2 } ) ;
828+
826829 el . setAttribute ( 'transform' , 'rotate(20deg)' ) ;
827830 expect ( Lib . getTranslate ( el ) ) . toEqual ( { x : 0 , y : 0 } ) ;
828831 } ) ;
@@ -884,6 +887,52 @@ describe('Test lib.js:', function() {
884887 } ) ;
885888 } ) ;
886889
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+
887936 describe ( 'setScale' , function ( ) {
888937
889938 it ( 'should work with regular DOM elements' , function ( ) {
0 commit comments