@@ -192,25 +192,18 @@ describe('main plot pan', function() {
192
192
var mock = Lib . extendDeep ( { } , require ( '@mocks/10.json' ) ) ;
193
193
mock . layout . dragmode = 'pan' ;
194
194
195
- function _drag ( x0 , y0 , x1 , y1 , n ) {
196
- mouseEvent ( 'mousedown' , x0 , y0 ) ;
197
- var dx = ( x1 - x0 ) / n ;
198
- var dy = ( y1 - y0 ) / n ;
199
- for ( var i = 0 ; i <= n ; i ++ ) {
200
- mouseEvent ( 'mousemove' , x0 + dx * i , y0 + dy * i ) ;
201
- }
202
- mouseEvent ( 'mouseup' , x1 , y1 ) ;
203
- }
195
+ var nsteps = 10 ;
196
+ var events = [ ] ;
197
+ var relayoutCallback ;
204
198
205
- var nsteps = 10 ; var events = [ ] ; var relayoutCallback ;
206
199
Plotly . plot ( gd , mock . data , mock . layout )
207
200
. then ( function ( ) {
208
201
relayoutCallback = jasmine . createSpy ( 'relayoutCallback' ) ;
209
202
gd . on ( 'plotly_relayout' , relayoutCallback ) ;
210
203
gd . on ( 'plotly_relayouting' , function ( e ) {
211
204
events . push ( e ) ;
212
205
} ) ;
213
- _drag ( 100 , 150 , 220 , 250 , nsteps ) ;
206
+ return drag ( { pos0 : [ 100 , 150 ] , posN : [ 220 , 250 ] , nsteps : nsteps } ) ;
214
207
} )
215
208
. then ( function ( ) {
216
209
expect ( events . length ) . toEqual ( nsteps ) ;
@@ -247,12 +240,10 @@ describe('main plot pan', function() {
247
240
}
248
241
249
242
function _run ( p0 , p1 , markerDisplay , textDisplay , barTextDisplay ) {
250
- mouseEvent ( 'mousedown' , p0 [ 0 ] , p0 [ 1 ] ) ;
251
- mouseEvent ( 'mousemove' , p1 [ 0 ] , p1 [ 1 ] ) ;
252
-
253
- _assert ( markerDisplay , textDisplay , barTextDisplay ) ;
254
-
255
- mouseEvent ( 'mouseup' , p1 [ 0 ] , p1 [ 1 ] ) ;
243
+ var fns = drag . makeFns ( { pos0 : p0 , posN : p1 } ) ;
244
+ return fns . start ( )
245
+ . then ( function ( ) { _assert ( markerDisplay , textDisplay , barTextDisplay ) ; } )
246
+ . then ( fns . end ) ;
256
247
}
257
248
258
249
Plotly . newPlot ( gd , [ {
@@ -283,25 +274,29 @@ describe('main plot pan', function() {
283
274
) ;
284
275
} )
285
276
. then ( function ( ) {
286
- _run (
277
+ return _run (
287
278
[ 250 , 250 ] , [ 250 , 150 ] ,
288
279
[ null , null , 'none' ] ,
289
280
[ null , null , 'none' ] ,
290
281
[ null , null , 'none' ]
291
282
) ;
283
+ } )
284
+ . then ( function ( ) {
292
285
expect ( gd . _fullLayout . yaxis . range [ 1 ] ) . toBeLessThan ( 3 ) ;
293
286
} )
294
287
. then ( function ( ) {
295
- _run (
288
+ return _run (
296
289
[ 250 , 250 ] , [ 150 , 250 ] ,
297
290
[ 'none' , null , 'none' ] ,
298
291
[ 'none' , null , 'none' ] ,
299
292
[ 'none' , null , 'none' ]
300
293
) ;
294
+ } )
295
+ . then ( function ( ) {
301
296
expect ( gd . _fullLayout . xaxis . range [ 0 ] ) . toBeGreaterThan ( 1 ) ;
302
297
} )
303
298
. then ( function ( ) {
304
- _run (
299
+ return _run (
305
300
[ 250 , 250 ] , [ 350 , 350 ] ,
306
301
[ null , null , null ] ,
307
302
[ null , null , null ] ,
0 commit comments