@@ -553,7 +553,7 @@ describe('config argument', function() {
553553
554554 describe ( 'responsive figure' , function ( ) {
555555 var gd ;
556- var data = [ { x : [ 1 , 2 , 3 , 4 ] , y : [ 5 , 10 , 2 , 8 ] } ] ;
556+ var data = [ { type : 'scatter' , x : [ 1 , 2 , 3 , 4 ] , y : [ 5 , 10 , 2 , 8 ] } ] ;
557557 var width = 960 ;
558558 var height = 800 ;
559559
@@ -580,10 +580,17 @@ describe('config argument', function() {
580580 function checkLayoutSize ( width , height ) {
581581 expect ( gd . _fullLayout . width ) . toBe ( width ) ;
582582 expect ( gd . _fullLayout . height ) . toBe ( height ) ;
583+ }
583584
584- var svg = document . getElementsByClassName ( 'main-svg' ) [ 0 ] ;
585- expect ( + svg . getAttribute ( 'width' ) ) . toBe ( width ) ;
586- expect ( + svg . getAttribute ( 'height' ) ) . toBe ( height ) ;
585+ function checkElementsSize ( nodeList , width , height ) {
586+ var i ;
587+ for ( i = 0 ; i < nodeList . length ; i ++ ) {
588+ var domRect = nodeList [ i ] . getBoundingClientRect ( ) ;
589+ expect ( domRect . width ) . toBe ( width ) ;
590+ expect ( domRect . height ) . toBe ( height ) ;
591+ expect ( + nodeList [ i ] . getAttribute ( 'width' ) ) . toBe ( width ) ;
592+ expect ( + nodeList [ i ] . getAttribute ( 'height' ) ) . toBe ( height ) ;
593+ }
587594 }
588595
589596 function testResponsive ( ) {
@@ -594,6 +601,13 @@ describe('config argument', function() {
594601 . then ( delay ( RESIZE_DELAY ) )
595602 . then ( function ( ) {
596603 checkLayoutSize ( elWidth / 2 , elHeight / 2 ) ;
604+
605+ var mainSvgs = document . getElementsByClassName ( 'main-svg' ) ;
606+ checkElementsSize ( mainSvgs , elWidth / 2 , elHeight / 2 ) ;
607+
608+ var canvases = document . getElementsByTagName ( 'canvas' ) ;
609+ checkElementsSize ( canvases , elWidth / 2 , elHeight / 2 ) ;
610+
597611 } )
598612 . catch ( failTest ) ;
599613 }
0 commit comments