@@ -5485,22 +5485,78 @@ describe('more react tests', function() {
54855485 expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { A : 0 , Z : 1 } ) ;
54865486 } )
54875487 . then ( function ( ) {
5488- var newFig = JSON . parse ( JSON . stringify ( fig ) ) ;
5489-
54905488 // flip order
5491- newFig . data [ 0 ] . x . reverse ( ) ;
5492- newFig . data [ 0 ] . y . reverse ( ) ;
5493- newFig . data [ 1 ] . x . reverse ( ) ;
5494- newFig . data [ 1 ] . y . reverse ( ) ;
5489+ fig . data [ 0 ] . x = [ 'Z' , 'A' ] ;
5490+ fig . data [ 1 ] . x = [ 'Z' , 'A' ] ;
54955491
5496- return Plotly . react ( gd , newFig ) ;
5492+ return Plotly . react ( gd , fig ) ;
5493+ } )
5494+ . then ( function ( ) {
5495+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
5496+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
5497+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
5498+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
5499+ } )
5500+ . then ( function ( ) {
5501+ // should get the same order with newPlot
5502+ return Plotly . newPlot ( gd , fig ) ;
54975503 } )
54985504 . then ( function ( ) {
54995505 expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
55005506 expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , 'A' ] ) ;
55015507 expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
55025508 expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , A : 1 } ) ;
55035509 } )
5510+ . then ( function ( ) {
5511+ // add new category
5512+ fig . data [ 0 ] . x = [ 'Z' , 0 , 'A' ] ;
5513+ fig . data [ 1 ] . x = [ 'Z' , 0 , 'A' ] ;
5514+ fig . data [ 0 ] . y = [ 1 , 2 , 3 ] ;
5515+ fig . data [ 1 ] . y = [ 2 , 4 , 6 ] ;
5516+
5517+ return Plotly . react ( gd , fig ) ;
5518+ } )
5519+ . then ( function ( ) {
5520+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5521+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5522+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5523+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5524+ } )
5525+ . then ( function ( ) {
5526+ // should get the same order with newPlot
5527+ return Plotly . newPlot ( gd , fig ) ;
5528+ } )
5529+ . then ( function ( ) {
5530+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5531+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5532+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5533+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5534+ } )
5535+ . then ( function ( ) {
5536+ // change data
5537+ fig . data [ 0 ] . x = [ 'Z' , 0 , 'A' ] ;
5538+ fig . data [ 1 ] . x = [ 'A' , 'Z' ] ;
5539+ fig . data [ 0 ] . y = [ 3 , 2 , 1 ] ;
5540+ fig . data [ 1 ] . y = [ - 1 , 0 ] ;
5541+
5542+ return Plotly . react ( gd , fig ) ;
5543+ } )
5544+ . then ( function ( ) {
5545+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5546+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5547+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5548+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5549+ } )
5550+ . then ( function ( ) {
5551+ // should get the same order with newPlot
5552+ return Plotly . newPlot ( gd , fig ) ;
5553+ } )
5554+ . then ( function ( ) {
5555+ expect ( gd . _fullLayout . xaxis . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5556+ expect ( gd . _fullLayout . xaxis2 . _categories ) . toEqual ( [ 'Z' , '0' , 'A' ] ) ;
5557+ expect ( gd . _fullLayout . xaxis . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5558+ expect ( gd . _fullLayout . xaxis2 . _categoriesMap ) . toEqual ( { Z : 0 , 0 : 1 , A : 2 } ) ;
5559+ } )
55045560 . catch ( failTest )
55055561 . then ( done ) ;
55065562 } ) ;
0 commit comments