@@ -314,6 +314,40 @@ describe('Drawing', function() {
314314 expect ( el . getAttribute ( 'transform' ) ) . toBe ( 'translate(1,2)' ) ;
315315 } ) ;
316316 } ) ;
317+
318+ describe ( 'setTextPointsScale' , function ( ) {
319+ var svg , g , text ;
320+
321+ beforeEach ( function ( ) {
322+ svg = d3 . select ( document . createElement ( 'svg' ) ) ;
323+ g = svg . append ( 'g' ) ;
324+ text = g . append ( 'text' ) ;
325+ } ) ;
326+
327+ it ( 'sets the transform on an empty element' , function ( ) {
328+ Drawing . setTextPointsScale ( g , 2 , 3 ) ;
329+ expect ( g . attr ( 'transform' ) ) . toEqual ( 'translate(0,0) scale(2,3) translate(0,0)' ) ;
330+ } ) ;
331+
332+ it ( 'unsets the transform' , function ( ) {
333+ Drawing . setTextPointsScale ( g , 1 , 1 ) ;
334+ expect ( g . attr ( 'transform' ) ) . toEqual ( '' ) ;
335+ } ) ;
336+
337+ it ( 'preserves a leading translate' , function ( ) {
338+ Drawing . setTextPointsScale ( g , 1 , 1 ) ;
339+ g . attr ( 'transform' , 'translate(1, 2)' ) ;
340+ expect ( g . attr ( 'transform' ) ) . toEqual ( 'translate(1, 2)' ) ;
341+ } ) ;
342+
343+ it ( 'preserves transforms' , function ( ) {
344+ text . attr ( 'x' , 8 ) ;
345+ text . attr ( 'y' , 9 ) ;
346+ g . attr ( 'transform' , 'translate(1, 2)' ) ;
347+ Drawing . setTextPointsScale ( g , 4 , 5 ) ;
348+ expect ( g . attr ( 'transform' ) ) . toEqual ( 'translate(8,9) scale(4,5) translate(-8,-9) translate(1, 2)' ) ;
349+ } ) ;
350+ } ) ;
317351} ) ;
318352
319353describe ( 'gradients' , function ( ) {
0 commit comments