@@ -826,14 +826,18 @@ describe('hover updates', function() {
826
826
827
827
setTimeout ( function ( ) {
828
828
var hoverText = d3 . selectAll ( 'g.hovertext' ) ;
829
- expect ( hoverText . size ( ) ) . toEqual ( 1 ) ;
830
- expect ( hoverText . text ( ) ) . toEqual ( labelText ) ;
831
-
832
- var transformParts = hoverText . attr ( 'transform' ) . split ( '(' ) ;
833
- expect ( transformParts [ 0 ] ) . toEqual ( 'translate' ) ;
834
- var transformCoords = transformParts [ 1 ] . split ( ')' ) [ 0 ] . split ( ',' ) ;
835
- expect ( + transformCoords [ 0 ] ) . toBeCloseTo ( labelPos [ 0 ] , - 1 , labelText + ':x' ) ;
836
- expect ( + transformCoords [ 1 ] ) . toBeCloseTo ( labelPos [ 1 ] , - 1 , labelText + ':y' ) ;
829
+ if ( labelPos ) {
830
+ expect ( hoverText . size ( ) ) . toEqual ( 1 ) ;
831
+ expect ( hoverText . text ( ) ) . toEqual ( labelText ) ;
832
+
833
+ var transformParts = hoverText . attr ( 'transform' ) . split ( '(' ) ;
834
+ expect ( transformParts [ 0 ] ) . toEqual ( 'translate' ) ;
835
+ var transformCoords = transformParts [ 1 ] . split ( ')' ) [ 0 ] . split ( ',' ) ;
836
+ expect ( + transformCoords [ 0 ] ) . toBeCloseTo ( labelPos [ 0 ] , - 1 , labelText + ':x' ) ;
837
+ expect ( + transformCoords [ 1 ] ) . toBeCloseTo ( labelPos [ 1 ] , - 1 , labelText + ':y' ) ;
838
+ } else {
839
+ expect ( hoverText . size ( ) ) . toEqual ( 0 ) ;
840
+ }
837
841
838
842
resolve ( ) ;
839
843
} , constants . HOVERMINTIME ) ;
@@ -868,6 +872,18 @@ describe('hover updates', function() {
868
872
// No mouse event this time. Just change the data and check the label.
869
873
// Ditto on concatenation. This is "trace 1" + "0.5"
870
874
return assertLabelsCorrect ( null , [ 103 , 100 ] , 'trace 10.5' ) ;
875
+ } ) . then ( function ( ) {
876
+ // Restyle to move the point out of the window:
877
+ return Plotly . relayout ( gd , { 'xaxis.range' : [ 2 , 3 ] } ) ;
878
+ } ) . then ( function ( ) {
879
+ // Assert label removed:
880
+ return assertLabelsCorrect ( null , null ) ;
881
+ } ) . then ( function ( ) {
882
+ // Move back to the original xaxis range:
883
+ return Plotly . relayout ( gd , { 'xaxis.range' : [ 0 , 1 ] } ) ;
884
+ } ) . then ( function ( ) {
885
+ // Assert label restored:
886
+ return assertLabelsCorrect ( null , [ 103 , 100 ] , 'trace 10.5' ) ;
871
887
} ) . catch ( fail ) . then ( done ) ;
872
888
} ) ;
873
889
} ) ;
0 commit comments