@@ -88,7 +88,7 @@ describe('Test gl plot interactions', function() {
8888
8989 describe ( 'scatter3d hover' , function ( ) {
9090
91- var node , ptData ;
91+ var ptData ;
9292
9393 beforeEach ( function ( done ) {
9494 gd . on ( 'plotly_hover' , function ( eventData ) {
@@ -100,14 +100,18 @@ describe('Test gl plot interactions', function() {
100100 delay ( done ) ;
101101 } ) ;
102102
103- it ( 'should have' , function ( ) {
104- node = d3 . selectAll ( 'g.hovertext' ) ;
103+ function assertHoverText ( xLabel , yLabel , zLabel ) {
104+ var node = d3 . selectAll ( 'g.hovertext' ) ;
105105 expect ( node . size ( ) ) . toEqual ( 1 , 'one hover text group' ) ;
106106
107- node = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'tspan' ) [ 0 ] ;
108- expect ( node [ 0 ] . innerHTML ) . toEqual ( 'x: 140.72' , 'x val on hover' ) ;
109- expect ( node [ 1 ] . innerHTML ) . toEqual ( 'y: −96.97' , 'y val on hover' ) ;
110- expect ( node [ 2 ] . innerHTML ) . toEqual ( 'z: −96.97' , 'z val on hover' ) ;
107+ var tspan = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'tspan' ) [ 0 ] ;
108+ expect ( tspan [ 0 ] . innerHTML ) . toEqual ( xLabel , 'x val on hover' ) ;
109+ expect ( tspan [ 1 ] . innerHTML ) . toEqual ( yLabel , 'y val on hover' ) ;
110+ expect ( tspan [ 2 ] . innerHTML ) . toEqual ( zLabel , 'z val on hover' ) ;
111+ }
112+
113+ it ( 'should have' , function ( done ) {
114+ assertHoverText ( 'x: 140.72' , 'y: −96.97' , 'z: −96.97' ) ;
111115
112116 expect ( Object . keys ( ptData ) ) . toEqual ( [
113117 'x' , 'y' , 'z' ,
@@ -119,8 +123,44 @@ describe('Test gl plot interactions', function() {
119123 expect ( ptData . z ) . toEqual ( '−96.97' , 'z val hover data' ) ;
120124 expect ( ptData . curveNumber ) . toEqual ( 0 , 'curveNumber hover data' ) ;
121125 expect ( ptData . pointNumber ) . toEqual ( 2 , 'pointNumber hover data' ) ;
122- } ) ;
123126
127+ Plotly . restyle ( gd , {
128+ x : [ [ '2016-01-11' , '2016-01-12' , '2017-01-01' , '2017-02' ] ]
129+ } )
130+ . then ( function ( ) {
131+ mouseEventScatter3d ( 'mouseover' ) ;
132+ return delay ;
133+ } )
134+ . then ( function ( ) {
135+ assertHoverText ( 'x: Jan 1, 2017' , 'y: −96.97' , 'z: −96.97' ) ;
136+
137+ return Plotly . restyle ( gd , {
138+ x : [ [ new Date ( 2017 , 2 , 1 ) , new Date ( 2017 , 2 , 2 ) , new Date ( 2017 , 2 , 3 ) , new Date ( 2017 , 2 , 4 ) ] ]
139+ } ) ;
140+ } )
141+ . then ( function ( ) {
142+ mouseEventScatter3d ( 'mouseover' ) ;
143+ return delay ;
144+ } )
145+ . then ( function ( ) {
146+ assertHoverText ( 'x: Mar 3, 2017' , 'y: −96.97' , 'z: −96.97' ) ;
147+
148+ return Plotly . update ( gd , {
149+ y : [ [ 'a' , 'b' , 'c' , 'd' ] ] ,
150+ z : [ [ 10 , 1e3 , 1e5 , 1e10 ] ]
151+ } , {
152+ 'scene.zaxis.type' : 'log'
153+ } ) ;
154+ } )
155+ . then ( function ( ) {
156+ mouseEventScatter3d ( 'mouseover' ) ;
157+ return delay ;
158+ } )
159+ . then ( function ( ) {
160+ assertHoverText ( 'x: Mar 3, 2017' , 'y: c' , 'z: 100k' ) ;
161+ } )
162+ . then ( done ) ;
163+ } ) ;
124164 } ) ;
125165
126166 describe ( 'scatter3d click events' , function ( ) {
0 commit comments