@@ -16,8 +16,9 @@ var customMatchers = require('../assets/custom_matchers');
1616 *
1717 */
1818
19- var PLOT_DELAY = 100 ;
19+ var PLOT_DELAY = 200 ;
2020var MOUSE_DELAY = 20 ;
21+ var MODEBAR_DELAY = 500 ;
2122
2223
2324describe ( 'Test gl plot interactions' , function ( ) {
@@ -48,32 +49,40 @@ describe('Test gl plot interactions', function() {
4849 destroyGraphDiv ( ) ;
4950 } ) ;
5051
52+ function delay ( done ) {
53+ setTimeout ( function ( ) {
54+ done ( ) ;
55+ } , PLOT_DELAY ) ;
56+ }
5157
5258 describe ( 'gl3d plots' , function ( ) {
5359 var mock = require ( '@mocks/gl3d_marker-arrays.json' ) ;
54- var gd ;
5560
5661 function mouseEventScatter3d ( type , opts ) {
5762 mouseEvent ( type , 605 , 271 , opts ) ;
5863 }
5964
6065 beforeEach ( function ( done ) {
6166 gd = createGraphDiv ( ) ;
62- Plotly . plot ( gd , mock . data , mock . layout ) . then ( done ) ;
67+ Plotly . plot ( gd , mock . data , mock . layout ) . then ( function ( ) {
68+ delay ( done ) ;
69+ } ) ;
6370 } ) ;
6471
6572 describe ( 'scatter3d hover' , function ( ) {
73+
6674 var node , ptData ;
6775
6876 beforeEach ( function ( done ) {
6977 gd . on ( 'plotly_hover' , function ( eventData ) {
7078 ptData = eventData . points [ 0 ] ;
7179 } ) ;
7280
81+ mouseEventScatter3d ( 'mouseover' ) ;
82+
7383 setTimeout ( function ( ) {
74- mouseEventScatter3d ( 'mouseover' ) ;
75- setTimeout ( done , MOUSE_DELAY ) ;
76- } , PLOT_DELAY ) ;
84+ done ( ) ;
85+ } , MOUSE_DELAY ) ;
7786 } ) ;
7887
7988 it ( 'should have' , function ( ) {
@@ -110,13 +119,13 @@ describe('Test gl plot interactions', function() {
110119 ptData = eventData . points [ 0 ] ;
111120 } ) ;
112121
113- setTimeout ( function ( ) {
122+ // N.B. gl3d click events are 'mouseover' events
123+ // with button 1 pressed
124+ mouseEventScatter3d ( 'mouseover' , { buttons : 1 } ) ;
114125
115- // N.B. gl3d click events are 'mouseover' events
116- // with button 1 pressed
117- mouseEventScatter3d ( 'mouseover' , { buttons : 1 } ) ;
118- setTimeout ( done , MOUSE_DELAY ) ;
119- } , PLOT_DELAY ) ;
126+ setTimeout ( function ( ) {
127+ done ( ) ;
128+ } , MOUSE_DELAY ) ;
120129 } ) ;
121130
122131 it ( 'should have' , function ( ) {
@@ -139,7 +148,11 @@ describe('Test gl plot interactions', function() {
139148 var mock = require ( '@mocks/gl2d_10.json' ) ;
140149
141150 beforeEach ( function ( done ) {
142- Plotly . plot ( createGraphDiv ( ) , mock . data , mock . layout ) . then ( done ) ;
151+ gd = createGraphDiv ( ) ;
152+
153+ Plotly . plot ( gd , mock . data , mock . layout ) . then ( function ( ) {
154+ delay ( done ) ;
155+ } ) ;
143156 } ) ;
144157
145158 it ( 'has one *canvas* node' , function ( ) {
@@ -149,7 +162,7 @@ describe('Test gl plot interactions', function() {
149162 } ) ;
150163
151164 describe ( 'gl3d modebar click handlers' , function ( ) {
152- var gd , modeBar ;
165+ var modeBar ;
153166
154167 beforeEach ( function ( done ) {
155168 var mockData = [ {
@@ -166,7 +179,8 @@ describe('Test gl plot interactions', function() {
166179 gd = createGraphDiv ( ) ;
167180 Plotly . plot ( gd , mockData , mockLayout ) . then ( function ( ) {
168181 modeBar = gd . _fullLayout . _modeBar ;
169- done ( ) ;
182+
183+ delay ( done ) ;
170184 } ) ;
171185 } ) ;
172186
@@ -249,9 +263,6 @@ describe('Test gl plot interactions', function() {
249263 } ) ;
250264
251265 describe ( 'buttons resetCameraDefault3d and resetCameraLastSave3d' , function ( ) {
252- // changes in scene objects are not instantaneous
253- var DELAY = 500 ;
254-
255266 it ( 'should update the scene camera' , function ( done ) {
256267 var sceneLayout = gd . _fullLayout . scene ,
257268 sceneLayout2 = gd . _fullLayout . scene2 ,
@@ -286,8 +297,8 @@ describe('Test gl plot interactions', function() {
286297 . toBeCloseToArray ( [ 2.5 , 2.5 , 2.5 ] , 4 ) ;
287298
288299 done ( ) ;
289- } , DELAY ) ;
290- } , DELAY ) ;
300+ } , MODEBAR_DELAY ) ;
301+ } , MODEBAR_DELAY ) ;
291302 } ) ;
292303 } ) ;
293304
0 commit comments