@@ -553,7 +553,7 @@ describe('config argument', function() {
553
553
554
554
describe ( 'responsive figure' , function ( ) {
555
555
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 ] } ] ;
557
557
var width = 960 ;
558
558
var height = 800 ;
559
559
@@ -580,10 +580,17 @@ describe('config argument', function() {
580
580
function checkLayoutSize ( width , height ) {
581
581
expect ( gd . _fullLayout . width ) . toBe ( width ) ;
582
582
expect ( gd . _fullLayout . height ) . toBe ( height ) ;
583
+ }
583
584
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
+ }
587
594
}
588
595
589
596
function testResponsive ( ) {
@@ -594,6 +601,13 @@ describe('config argument', function() {
594
601
. then ( delay ( RESIZE_DELAY ) )
595
602
. then ( function ( ) {
596
603
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
+
597
611
} )
598
612
. catch ( failTest ) ;
599
613
}
0 commit comments