@@ -174,44 +174,6 @@ describe('config argument', function() {
174174 . then ( done ) ;
175175 } ) ;
176176
177- it ( 'should provide a fixed non-zero width/height when autosize: true and container\' size is zero' , function ( done ) {
178- gd . style . display = 'inline-block' ;
179- Plotly . plot ( gd , data , { autosize : true } )
180- . then ( function ( ) {
181- checkLayoutSize ( 700 , 450 ) ;
182- expect ( gd . clientWidth ) . toBe ( 700 ) ;
183- expect ( gd . clientHeight ) . toBe ( 450 ) ;
184- } )
185- . then ( function ( ) {
186- return Plotly . newPlot ( gd , data , { autosize : true } ) ;
187- } )
188- // It is important to test newPlot to make sure an initially zero size container
189- // is still considered to have zero size after a plot is drawn into it.
190- . then ( function ( ) {
191- checkLayoutSize ( 700 , 450 ) ;
192- expect ( gd . clientWidth ) . toBe ( 700 ) ;
193- expect ( gd . clientHeight ) . toBe ( 450 ) ;
194- } )
195- . catch ( failTest )
196- . then ( done ) ;
197- } ) ;
198-
199- // The following test is to guarantee we're not breaking the existing behaviour which may not be ideal.
200- // In a future version, one may prefer autosize:true winning over an explicit width/height when embedded in a webpage.
201- it ( 'should use the explicitly provided width/height even if autosize:true' , function ( done ) {
202- gd . style . width = '1000px' ;
203- gd . style . height = '500px' ;
204- Plotly . plot ( gd , data , { autosize : true , width : 1200 , height : 700 } )
205- . then ( function ( ) {
206- expect ( gd . clientWidth ) . toBe ( 1000 ) ;
207- expect ( gd . clientHeight ) . toBe ( 500 ) ;
208- // The plot should overflow the container!
209- checkLayoutSize ( 1200 , 700 ) ;
210- } )
211- . catch ( failTest )
212- . then ( done ) ;
213- } ) ;
214-
215177 it ( 'should respect attribute autosizable: false' , function ( done ) {
216178 var autosize = false ;
217179 var config = {
@@ -743,5 +705,50 @@ describe('config argument', function() {
743705 . then ( testResponsive )
744706 . then ( done ) ;
745707 } ) ;
708+
709+ it ( 'should provide a fixed non-zero width/height when autosize/responsive: true and container\' size is zero' , function ( done ) {
710+ fillParent ( 1 , 1 , function ( ) {
711+ this . style . display = 'inline-block' ;
712+ this . style . width = null ;
713+ this . style . height = null ;
714+ } ) ;
715+ Plotly . plot ( gd , data , { autosize : true } , { responsive : true } )
716+ . then ( function ( ) {
717+ checkLayoutSize ( 700 , 450 ) ;
718+ expect ( gd . clientWidth ) . toBe ( 700 ) ;
719+ expect ( gd . clientHeight ) . toBe ( 450 ) ;
720+ } )
721+ . then ( function ( ) {
722+ return Plotly . newPlot ( gd , data , { autosize : true } , { responsive : true } ) ;
723+ } )
724+ // It is important to test newPlot to make sure an initially zero size container
725+ // is still considered to have zero size after a plot is drawn into it.
726+ . then ( function ( ) {
727+ checkLayoutSize ( 700 , 450 ) ;
728+ expect ( gd . clientWidth ) . toBe ( 700 ) ;
729+ expect ( gd . clientHeight ) . toBe ( 450 ) ;
730+ } )
731+ . catch ( failTest )
732+ . then ( done ) ;
733+ } ) ;
734+
735+ // The following test is to guarantee we're not breaking the existing (although maybe not ideal) behaviour.
736+ // In a future version, one may prefer responsive/autosize:true winning over an explicit width/height when embedded in a webpage.
737+ it ( 'should use the explicitly provided width/height even if autosize/responsive:true' , function ( done ) {
738+ fillParent ( 1 , 1 , function ( ) {
739+ this . style . width = '1000px' ;
740+ this . style . height = '500px' ;
741+ } ) ;
742+
743+ Plotly . plot ( gd , data , { autosize : true , width : 1200 , height : 700 } , { responsive : true } )
744+ . then ( function ( ) {
745+ expect ( gd . clientWidth ) . toBe ( 1000 ) ;
746+ expect ( gd . clientHeight ) . toBe ( 500 ) ;
747+ // The plot should overflow the container!
748+ checkLayoutSize ( 1200 , 700 ) ;
749+ } )
750+ . catch ( failTest )
751+ . then ( done ) ;
752+ } ) ;
746753 } ) ;
747754} ) ;
0 commit comments