@@ -2465,7 +2465,7 @@ describe('Test axes', function() {
24652465 'short label 5' , 'loooooong label 5'
24662466 ]
24672467 } ] ,
2468- gd ;
2468+ gd , initialSize , previousSize , savedBottom ;
24692469
24702470 beforeEach ( function ( ) {
24712471 gd = createGraphDiv ( ) ;
@@ -2477,87 +2477,98 @@ describe('Test axes', function() {
24772477
24782478 Plotly . plot ( gd , data )
24792479 . then ( function ( ) {
2480- var size = gd . _fullLayout . _size ;
2481- // these are the defaults
2482- expect ( size . l ) . toBe ( 80 ) ;
2483- expect ( size . r ) . toBe ( 80 ) ;
2484- expect ( size . b ) . toBe ( 80 ) ;
2485- expect ( size . t ) . toBe ( 100 ) ;
2480+ initialSize = Lib . extendDeep ( { } , gd . _fullLayout . _size ) ;
24862481 expect ( gd . _fullLayout . xaxis . _lastangle ) . toBe ( 30 ) ;
24872482 } )
24882483 . then ( function ( ) {
2484+ previousSize = Lib . extendDeep ( { } , gd . _fullLayout . _size ) ;
24892485 return Plotly . relayout ( gd , { 'yaxis.automargin' : true } ) ;
24902486 } )
24912487 . then ( function ( ) {
24922488 var size = gd . _fullLayout . _size ;
2493- expect ( size . l ) . toBe ( 133 ) ; // left side grows
2494- expect ( size . r ) . toBe ( 80 ) ;
2495- expect ( size . b ) . toBe ( 80 ) ;
2496- expect ( size . t ) . toBe ( 100 ) ;
2489+ expect ( size . l ) . toBeGreaterThan ( previousSize . l ) ;
2490+ expect ( size . r ) . toBe ( previousSize . r ) ;
2491+ expect ( size . b ) . toBe ( previousSize . b ) ;
2492+ expect ( size . t ) . toBe ( previousSize . t ) ;
24972493 } )
24982494 . then ( function ( ) {
2495+ previousSize = Lib . extendDeep ( { } , gd . _fullLayout . _size ) ;
24992496 return Plotly . relayout ( gd , { 'xaxis.automargin' : true } ) ;
25002497 } )
25012498 . then ( function ( ) {
25022499 var size = gd . _fullLayout . _size ;
2503- expect ( size . l ) . toBe ( 133 ) ;
2504- expect ( size . r ) . toBe ( 80 ) ;
2505- expect ( size . b ) . toBe ( 154 ) ; // bottom grows
2506- expect ( size . t ) . toBe ( 100 ) ;
2500+ expect ( size . l ) . toBe ( previousSize . l ) ;
2501+ expect ( size . r ) . toBe ( previousSize . r ) ;
2502+ expect ( size . b ) . toBeGreaterThan ( previousSize . b ) ;
2503+ expect ( size . t ) . toBe ( previousSize . t ) ;
25072504 } )
25082505 . then ( function ( ) {
2506+ previousSize = Lib . extendDeep ( { } , gd . _fullLayout . _size ) ;
2507+ savedBottom = previousSize . b ;
25092508 return Plotly . relayout ( gd , { 'xaxis.tickangle' : 45 } ) ;
25102509 } )
25112510 . then ( function ( ) {
25122511 var size = gd . _fullLayout . _size ;
2513- expect ( size . l ) . toBe ( 133 ) ;
2514- expect ( size . r ) . toBe ( 80 ) ;
2515- expect ( size . b ) . toBe ( 200 ) ; // bottom grows more
2516- expect ( size . t ) . toBe ( 100 ) ;
2512+ expect ( size . l ) . toBe ( previousSize . l ) ;
2513+ expect ( size . r ) . toBe ( previousSize . r ) ;
2514+ expect ( size . b ) . toBeGreaterThan ( previousSize . b ) ;
2515+ expect ( size . t ) . toBe ( previousSize . t ) ;
25172516 } )
25182517 . then ( function ( ) {
2518+ previousSize = Lib . extendDeep ( { } , gd . _fullLayout . _size ) ;
25192519 return Plotly . relayout ( gd , { 'xaxis.tickangle' : 30 } ) ;
25202520 } )
25212521 . then ( function ( ) {
25222522 var size = gd . _fullLayout . _size ;
2523- expect ( size . l ) . toBe ( 133 ) ;
2524- expect ( size . r ) . toBe ( 80 ) ;
2525- expect ( size . b ) . toBe ( 154 ) ; // bottom shrinks back
2526- expect ( size . t ) . toBe ( 100 ) ;
2523+ expect ( size . l ) . toBe ( previousSize . l ) ;
2524+ expect ( size . r ) . toBe ( previousSize . r ) ;
2525+ expect ( size . b ) . toBe ( savedBottom ) ;
2526+ expect ( size . t ) . toBe ( previousSize . t ) ;
25272527 } )
25282528 . then ( function ( ) {
2529+ previousSize = Lib . extendDeep ( { } , gd . _fullLayout . _size ) ;
25292530 return Plotly . relayout ( gd , { 'yaxis.ticklen' : 30 } ) ;
25302531 } )
25312532 . then ( function ( ) {
25322533 var size = gd . _fullLayout . _size ;
2533- expect ( size . l ) . toBe ( 165 ) ; // left grows for tick length
2534- expect ( size . r ) . toBe ( 80 ) ;
2535- expect ( size . b ) . toBe ( 154 ) ;
2536- expect ( size . t ) . toBe ( 100 ) ;
2534+ expect ( size . l ) . toBeGreaterThan ( previousSize . l ) ;
2535+ expect ( size . r ) . toBe ( previousSize . r ) ;
2536+ expect ( size . b ) . toBe ( previousSize . b ) ;
2537+ expect ( size . t ) . toBe ( previousSize . t ) ;
25372538 } )
25382539 . then ( function ( ) {
2540+ previousSize = Lib . extendDeep ( { } , gd . _fullLayout . _size ) ;
25392541 return Plotly . relayout ( gd , { 'yaxis.titlefont.size' : 30 } ) ;
25402542 } )
25412543 . then ( function ( ) {
25422544 var size = gd . _fullLayout . _size ;
2543- expect ( size . l ) . toBe ( 181 ) ; // left grows for axis title font size
2544- expect ( size . r ) . toBe ( 80 ) ;
2545- expect ( size . b ) . toBe ( 154 ) ;
2546- expect ( size . t ) . toBe ( 100 ) ;
2545+ expect ( size ) . toEqual ( previousSize ) ;
2546+ } )
2547+ . then ( function ( ) {
2548+ previousSize = Lib . extendDeep ( { } , gd . _fullLayout . _size ) ;
2549+ return Plotly . relayout ( gd , { 'yaxis.title' : 'hello' } ) ;
2550+ } )
2551+ . then ( function ( ) {
2552+ var size = gd . _fullLayout . _size ;
2553+ expect ( size . l ) . toBeGreaterThan ( previousSize . l ) ;
2554+ expect ( size . r ) . toBe ( previousSize . r ) ;
2555+ expect ( size . b ) . toBe ( previousSize . b ) ;
2556+ expect ( size . t ) . toBe ( previousSize . t ) ;
25472557 } )
25482558 . then ( function ( ) {
2559+ previousSize = Lib . extendDeep ( { } , gd . _fullLayout . _size ) ;
25492560 return Plotly . relayout ( gd , {
25502561 'yaxis.side' : 'right' ,
25512562 'xaxis.side' : 'top'
25522563 } ) ;
25532564 } )
25542565 . then ( function ( ) {
25552566 var size = gd . _fullLayout . _size ;
2556- // left- right and top- bottom swap
2557- expect ( size . l ) . toBe ( 80 ) ;
2558- expect ( size . r ) . toBe ( 181 ) ;
2559- expect ( size . b ) . toBe ( 80 ) ;
2560- expect ( size . t ) . toBe ( 154 ) ;
2567+ // left to right and bottom to top
2568+ expect ( size . l ) . toBe ( initialSize . r ) ;
2569+ expect ( size . r ) . toBe ( previousSize . l ) ;
2570+ expect ( size . b ) . toBe ( initialSize . b ) ;
2571+ expect ( size . t ) . toBe ( previousSize . b ) ;
25612572 } )
25622573 . then ( function ( ) {
25632574 return Plotly . relayout ( gd , {
@@ -2568,10 +2579,7 @@ describe('Test axes', function() {
25682579 . then ( function ( ) {
25692580 var size = gd . _fullLayout . _size ;
25702581 // back to the defaults
2571- expect ( size . l ) . toBe ( 80 ) ;
2572- expect ( size . r ) . toBe ( 80 ) ;
2573- expect ( size . b ) . toBe ( 80 ) ;
2574- expect ( size . t ) . toBe ( 100 ) ;
2582+ expect ( size ) . toEqual ( initialSize ) ;
25752583 } )
25762584 . catch ( failTest )
25772585 . then ( done ) ;
0 commit comments