@@ -811,11 +811,16 @@ describe('Test sunburst clicks:', function() {
811811 if ( trackers . sunburstclick . length === 1 ) {
812812 expect ( trackers . sunburstclick [ 0 ] . event ) . toBeDefined ( ) ;
813813 expect ( trackers . sunburstclick [ 0 ] . points [ 0 ] . label ) . toBe ( 'Seth' ) ;
814+ expect ( trackers . sunburstclick [ 0 ] . nextLevel ) . toBe ( 'Seth' ) ;
814815 } else {
815816 fail ( 'incorrect plotly_sunburstclick triggering' ) ;
816817 }
817818
818- if ( trackers . click . length ) {
819+ if ( trackers . click . length === 1 ) {
820+ expect ( trackers . click [ 0 ] . event ) . toBeDefined ( ) ;
821+ expect ( trackers . click [ 0 ] . points [ 0 ] . label ) . toBe ( 'Seth' ) ;
822+ expect ( trackers . click [ 0 ] . nextLevel ) . not . toBeDefined ( ) ;
823+ } else {
819824 fail ( 'incorrect plotly_click triggering' ) ;
820825 }
821826
@@ -888,16 +893,6 @@ describe('Test sunburst clicks:', function() {
888893 it ( 'should not trigger animation when graph is transitioning' , function ( done ) {
889894 var mock = Lib . extendDeep ( { } , require ( '@mocks/sunburst_first.json' ) ) ;
890895
891- // should be same before and after 2nd click
892- function _assertCommon ( msg ) {
893- if ( trackers . click . length ) {
894- fail ( 'incorrect plotly_click triggering - ' + msg ) ;
895- }
896- if ( trackers . animating . length !== 1 ) {
897- fail ( 'incorrect plotly_animating triggering - ' + msg ) ;
898- }
899- }
900-
901896 Plotly . plot ( gd , mock )
902897 . then ( setupListeners ( ) )
903898 . then ( click ( gd , 2 ) )
@@ -907,27 +902,49 @@ describe('Test sunburst clicks:', function() {
907902 if ( trackers . sunburstclick . length === 1 ) {
908903 expect ( trackers . sunburstclick [ 0 ] . event ) . toBeDefined ( msg ) ;
909904 expect ( trackers . sunburstclick [ 0 ] . points [ 0 ] . label ) . toBe ( 'Seth' , msg ) ;
905+ expect ( trackers . sunburstclick [ 0 ] . nextLevel ) . toBe ( 'Seth' , msg ) ;
910906 } else {
911907 fail ( 'incorrect plotly_sunburstclick triggering - ' + msg ) ;
912908 }
913909
914- _assertCommon ( msg ) ;
910+ if ( trackers . click . length === 1 ) {
911+ expect ( trackers . click [ 0 ] . event ) . toBeDefined ( msg ) ;
912+ expect ( trackers . click [ 0 ] . points [ 0 ] . label ) . toBe ( 'Seth' , msg ) ;
913+ expect ( trackers . click [ 0 ] . nextLevel ) . not . toBeDefined ( msg ) ;
914+ } else {
915+ fail ( 'incorrect plotly_click triggering - ' + msg ) ;
916+ }
917+
918+ if ( trackers . animating . length !== 1 ) {
919+ fail ( 'incorrect plotly_animating triggering - ' + msg ) ;
920+ }
915921 } )
916922 . then ( click ( gd , 4 ) )
917923 . then ( function ( ) {
918924 var msg = 'after 2nd click' ;
919925
920- // should trigger plotly_sunburstclick twice, but not additional
921- // plotly_click nor plotly_animating
926+ // should trigger plotly_sunburstclick and plotly_click twice,
927+ // but not plotly_animating
922928
923929 if ( trackers . sunburstclick . length === 2 ) {
924930 expect ( trackers . sunburstclick [ 0 ] . event ) . toBeDefined ( msg ) ;
925931 expect ( trackers . sunburstclick [ 0 ] . points [ 0 ] . label ) . toBe ( 'Awan' , msg ) ;
932+ expect ( trackers . sunburstclick [ 0 ] . nextLevel ) . toBe ( 'Awan' , msg ) ;
926933 } else {
927934 fail ( 'incorrect plotly_sunburstclick triggering - ' + msg ) ;
928935 }
929936
930- _assertCommon ( msg ) ;
937+ if ( trackers . click . length === 2 ) {
938+ expect ( trackers . click [ 0 ] . event ) . toBeDefined ( msg ) ;
939+ expect ( trackers . click [ 0 ] . points [ 0 ] . label ) . toBe ( 'Awan' , msg ) ;
940+ expect ( trackers . click [ 0 ] . nextLevel ) . not . toBeDefined ( msg ) ;
941+ } else {
942+ fail ( 'incorrect plotly_click triggering - ' + msg ) ;
943+ }
944+
945+ if ( trackers . animating . length !== 1 ) {
946+ fail ( 'incorrect plotly_animating triggering - ' + msg ) ;
947+ }
931948 } )
932949 . catch ( failTest )
933950 . then ( done ) ;
@@ -947,10 +964,7 @@ describe('Test sunburst clicks:', function() {
947964 fail ( 'incorrect plotly_sunburstclick triggering' ) ;
948965 }
949966
950- if ( trackers . click . length === 1 ) {
951- expect ( trackers . click [ 0 ] . event ) . toBeDefined ( ) ;
952- expect ( trackers . click [ 0 ] . points [ 0 ] . label ) . toBe ( 'Seth' ) ;
953- } else {
967+ if ( trackers . click . length !== 0 ) {
954968 fail ( 'incorrect plotly_click triggering' ) ;
955969 }
956970
0 commit comments