@@ -510,6 +510,43 @@ describe('Test plot api', function() {
510510 . catch ( failTest )
511511 . then ( done ) ;
512512 } ) ;
513+
514+ it ( 'updates autosize/width/height correctly' , function ( done ) {
515+ function assertSizeAndThen ( width , height , auto , msg , next ) {
516+ return function ( ) {
517+ expect ( gd . _fullLayout . width ) . toBe ( width , msg ) ;
518+ expect ( gd . _fullLayout . height ) . toBe ( height , msg ) ;
519+ expect ( gd . _fullLayout . autosize ) . toBe ( auto , msg ) ;
520+ if ( ! auto ) {
521+ expect ( gd . layout . width ) . toBe ( width , msg ) ;
522+ expect ( gd . layout . height ) . toBe ( height , msg ) ;
523+ }
524+
525+ if ( next ) return Plotly . relayout ( gd , next ) ;
526+ } ;
527+ }
528+
529+ // give gd css sizing to be picked up by autosize
530+ gd . style . width = '543px' ;
531+ gd . style . height = '432px' ;
532+
533+ Plotly . newPlot ( gd , [ { y : [ 1 , 3 , 2 ] } ] )
534+ . then ( assertSizeAndThen ( 543 , 432 , true , 'initial' ,
535+ { autosize : false } ) )
536+ . then ( assertSizeAndThen ( 543 , 432 , false , 'autosize false with no sizes' ,
537+ { autosize : true } ) )
538+ . then ( assertSizeAndThen ( 543 , 432 , true , 'back to autosized' ,
539+ { width : 600 } ) )
540+ . then ( assertSizeAndThen ( 600 , 432 , false , 'explicit width causes explicit height' ,
541+ { width : null } ) )
542+ . then ( assertSizeAndThen ( 543 , 432 , true , 'removed width' ,
543+ { height : 500 , width : 700 } ) )
544+ . then ( assertSizeAndThen ( 700 , 500 , false , 'explicit height and width' ,
545+ { autosize : true } ) )
546+ . then ( assertSizeAndThen ( 543 , 432 , true , 'final back to autosize' ) )
547+ . catch ( failTest )
548+ . then ( done ) ;
549+ } ) ;
513550 } ) ;
514551
515552 describe ( 'Plotly.relayout subroutines switchboard' , function ( ) {
0 commit comments