@@ -858,9 +858,6 @@ describe('Test lib.js:', function() {
858858 Lib . setTranslate ( el , 10 , 20 ) ;
859859 expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'translate(10, 20)' ) ;
860860
861- Lib . setTranslate ( el , 30 , 40 ) ;
862- expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'translate(30, 40)' ) ;
863-
864861 Lib . setTranslate ( el ) ;
865862 expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'translate(0, 0)' ) ;
866863
@@ -875,9 +872,6 @@ describe('Test lib.js:', function() {
875872 Lib . setTranslate ( el , 5 ) ;
876873 expect ( el . attr ( 'transform' ) ) . toBe ( 'translate(5, 0)' ) ;
877874
878- Lib . setTranslate ( el , 10 , 20 ) ;
879- expect ( el . attr ( 'transform' ) ) . toBe ( 'translate(10, 20)' ) ;
880-
881875 Lib . setTranslate ( el , 30 , 40 ) ;
882876 expect ( el . attr ( 'transform' ) ) . toBe ( 'translate(30, 40)' ) ;
883877
@@ -890,6 +884,43 @@ describe('Test lib.js:', function() {
890884 } ) ;
891885 } ) ;
892886
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+
893924 describe ( 'pushUnique' , function ( ) {
894925
895926 beforeEach ( function ( ) {
0 commit comments