@@ -102,46 +102,46 @@ describe('Test gl plot interactions', function() {
102
102
103
103
function assertHoverText ( xLabel , yLabel , zLabel ) {
104
104
var node = d3 . selectAll ( 'g.hovertext' ) ;
105
- expect ( node . size ( ) ) . toEqual ( 1 , 'one hover text group' ) ;
105
+ expect ( node . size ( ) ) . toEqual ( 1 , 'hover text group' ) ;
106
106
107
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 ' ) ;
108
+ expect ( tspan [ 0 ] . innerHTML ) . toEqual ( xLabel , 'x val' ) ;
109
+ expect ( tspan [ 1 ] . innerHTML ) . toEqual ( yLabel , 'y val' ) ;
110
+ expect ( tspan [ 2 ] . innerHTML ) . toEqual ( zLabel , 'z val' ) ;
111
111
}
112
112
113
- it ( 'should have' , function ( done ) {
113
+ it ( 'makes the right hover text and point data' , function ( done ) {
114
+
115
+ function hover ( ) {
116
+ mouseEventScatter3d ( 'mouseover' ) ;
117
+ return delay ;
118
+ }
119
+
114
120
assertHoverText ( 'x: 140.72' , 'y: −96.97' , 'z: −96.97' ) ;
115
121
116
122
expect ( Object . keys ( ptData ) ) . toEqual ( [
117
123
'x' , 'y' , 'z' ,
118
124
'data' , 'fullData' , 'curveNumber' , 'pointNumber'
119
125
] , 'correct hover data fields' ) ;
120
126
121
- expect ( ptData . x ) . toBe ( '140.72' , 'x val hover data ' ) ;
122
- expect ( ptData . y ) . toBe ( '−96.97' , 'y val hover data ' ) ;
123
- expect ( ptData . z ) . toEqual ( '−96.97' , 'z val hover data ' ) ;
124
- expect ( ptData . curveNumber ) . toEqual ( 0 , 'curveNumber hover data ' ) ;
125
- expect ( ptData . pointNumber ) . toEqual ( 2 , 'pointNumber hover data ' ) ;
127
+ expect ( ptData . x ) . toBe ( '140.72' , 'x val' ) ;
128
+ expect ( ptData . y ) . toBe ( '−96.97' , 'y val' ) ;
129
+ expect ( ptData . z ) . toEqual ( '−96.97' , 'z val' ) ;
130
+ expect ( ptData . curveNumber ) . toEqual ( 0 , 'curveNumber' ) ;
131
+ expect ( ptData . pointNumber ) . toEqual ( 2 , 'pointNumber' ) ;
126
132
127
133
Plotly . restyle ( gd , {
128
134
x : [ [ '2016-01-11' , '2016-01-12' , '2017-01-01' , '2017-02' ] ]
129
135
} )
130
- . then ( function ( ) {
131
- mouseEventScatter3d ( 'mouseover' ) ;
132
- return delay ;
133
- } )
136
+ . then ( hover )
134
137
. then ( function ( ) {
135
138
assertHoverText ( 'x: Jan 1, 2017' , 'y: −96.97' , 'z: −96.97' ) ;
136
139
137
140
return Plotly . restyle ( gd , {
138
141
x : [ [ new Date ( 2017 , 2 , 1 ) , new Date ( 2017 , 2 , 2 ) , new Date ( 2017 , 2 , 3 ) , new Date ( 2017 , 2 , 4 ) ] ]
139
142
} ) ;
140
143
} )
141
- . then ( function ( ) {
142
- mouseEventScatter3d ( 'mouseover' ) ;
143
- return delay ;
144
- } )
144
+ . then ( hover )
145
145
. then ( function ( ) {
146
146
assertHoverText ( 'x: Mar 3, 2017' , 'y: −96.97' , 'z: −96.97' ) ;
147
147
@@ -152,10 +152,7 @@ describe('Test gl plot interactions', function() {
152
152
'scene.zaxis.type' : 'log'
153
153
} ) ;
154
154
} )
155
- . then ( function ( ) {
156
- mouseEventScatter3d ( 'mouseover' ) ;
157
- return delay ;
158
- } )
155
+ . then ( hover )
159
156
. then ( function ( ) {
160
157
assertHoverText ( 'x: Mar 3, 2017' , 'y: c' , 'z: 100k' ) ;
161
158
} )
0 commit comments