@@ -308,4 +308,38 @@ describe('Drawing', function() {
308308 expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'translate(1,2)' ) ;
309309 } ) ;
310310 } ) ;
311+
312+ describe ( 'setTextPointsScale' , function ( ) {
313+ var svg , g , text ;
314+
315+ beforeEach ( function ( ) {
316+ svg = d3 . select ( document . createElement ( 'svg' ) ) ;
317+ g = svg . append ( 'g' ) ;
318+ text = g . append ( 'text' ) ;
319+ } ) ;
320+
321+ it ( 'sets the transform on an empty element' , function ( ) {
322+ Drawing . setTextPointsScale ( g , 2 , 3 ) ;
323+ expect ( g . attr ( 'transform' ) ) . toEqual ( 'translate(0,0) scale(2,3) translate(0,0)' ) ;
324+ } ) ;
325+
326+ it ( 'unsets the transform' , function ( ) {
327+ Drawing . setTextPointsScale ( g , 1 , 1 ) ;
328+ expect ( g . attr ( 'transform' ) ) . toEqual ( '' ) ;
329+ } ) ;
330+
331+ it ( 'preserves a leading translate' , function ( ) {
332+ Drawing . setTextPointsScale ( g , 1 , 1 ) ;
333+ g . attr ( 'transform' , 'translate(1, 2)' ) ;
334+ expect ( g . attr ( 'transform' ) ) . toEqual ( 'translate(1, 2)' ) ;
335+ } ) ;
336+
337+ it ( 'preserves transforms' , function ( ) {
338+ text . attr ( 'x' , 8 ) ;
339+ text . attr ( 'y' , 9 ) ;
340+ g . attr ( 'transform' , 'translate(1, 2)' ) ;
341+ Drawing . setTextPointsScale ( g , 4 , 5 ) ;
342+ expect ( g . attr ( 'transform' ) ) . toEqual ( 'translate(8,9) scale(4,5) translate(-8,-9) translate(1, 2)' ) ;
343+ } ) ;
344+ } ) ;
311345} ) ;
0 commit comments