@@ -181,9 +181,12 @@ describe('main plot pan', function() {
181181describe ( 'axis zoom/pan and main plot zoom' , function ( ) {
182182 var gd ;
183183
184+ beforeAll ( function ( ) {
185+ jasmine . addMatchers ( customMatchers ) ;
186+ } ) ;
187+
184188 beforeEach ( function ( ) {
185189 gd = createGraphDiv ( ) ;
186- jasmine . addMatchers ( customMatchers ) ;
187190 } ) ;
188191
189192 afterEach ( destroyGraphDiv ) ;
@@ -240,11 +243,7 @@ describe('axis zoom/pan and main plot zoom', function() {
240243 if ( layoutEdits ) Lib . extendDeep ( layout , layoutEdits ) ;
241244
242245 return Plotly . newPlot ( gd , data , layout , config ) . then ( function ( ) {
243- [
244- 'xaxis' , 'yaxis' , 'xaxis2' , 'yaxis2' , 'xaxis3' , 'yaxis3'
245- ] . forEach ( function ( axName ) {
246- expect ( gd . _fullLayout [ axName ] . range ) . toEqual ( initialRange ) ;
247- } ) ;
246+ checkRanges ( { } , 'initial' ) ;
248247
249248 expect ( Object . keys ( gd . _fullLayout . _plots ) )
250249 . toEqual ( [ 'xy' , 'xy2' , 'x2y' , 'x3y3' ] ) ;
@@ -276,7 +275,9 @@ describe('axis zoom/pan and main plot zoom', function() {
276275 return function ( ) { return doubleClick ( getDragger ( subplot , directions ) ) ; } ;
277276 }
278277
279- function checkRanges ( newRanges ) {
278+ function checkRanges ( newRanges , msg ) {
279+ msg = msg || '' ;
280+ if ( msg ) msg = ' - ' + msg ;
280281 return function ( ) {
281282 var allRanges = {
282283 xaxis : initialRange . slice ( ) ,
@@ -289,8 +290,8 @@ describe('axis zoom/pan and main plot zoom', function() {
289290 Lib . extendDeep ( allRanges , newRanges ) ;
290291
291292 for ( var axName in allRanges ) {
292- expect ( gd . layout [ axName ] . range ) . toBeCloseToArray ( allRanges [ axName ] , 3 , axName ) ;
293- expect ( gd . _fullLayout [ axName ] . range ) . toBeCloseToArray ( gd . layout [ axName ] . range , 6 , axName ) ;
293+ expect ( gd . layout [ axName ] . range ) . toBeCloseToArray ( allRanges [ axName ] , 3 , axName + msg ) ;
294+ expect ( gd . _fullLayout [ axName ] . range ) . toBeCloseToArray ( gd . layout [ axName ] . range , 6 , axName + msg ) ;
294295 }
295296 } ;
296297 }
@@ -299,45 +300,45 @@ describe('axis zoom/pan and main plot zoom', function() {
299300 makePlot ( )
300301 // zoombox into a small point - drag starts from the center unless you specify otherwise
301302 . then ( doDrag ( 'xy' , 'nsew' , 100 , - 50 ) )
302- . then ( checkRanges ( { xaxis : [ 1 , 2 ] , yaxis : [ 1 , 1.5 ] } ) )
303+ . then ( checkRanges ( { xaxis : [ 1 , 2 ] , yaxis : [ 1 , 1.5 ] } , 'zoombox' ) )
303304
304305 // first dblclick reverts to saved ranges
305306 . then ( doDblClick ( 'xy' , 'nsew' ) )
306- . then ( checkRanges ( ) )
307+ . then ( checkRanges ( { } , 'dblclick #1' ) )
307308 // next dblclick autoscales (just that plot)
308309 . then ( doDblClick ( 'xy' , 'nsew' ) )
309- . then ( checkRanges ( { xaxis : autoRange , yaxis : autoRange } ) )
310+ . then ( checkRanges ( { xaxis : autoRange , yaxis : autoRange } , 'dblclick #2' ) )
310311 // dblclick on one axis reverts just that axis to saved
311312 . then ( doDblClick ( 'xy' , 'ns' ) )
312- . then ( checkRanges ( { xaxis : autoRange } ) )
313+ . then ( checkRanges ( { xaxis : autoRange } , 'dblclick y' ) )
313314 // dblclick the plot at this point (one axis default, the other autoscaled)
314315 // and the whole thing is reverted to default
315316 . then ( doDblClick ( 'xy' , 'nsew' ) )
316- . then ( checkRanges ( ) )
317+ . then ( checkRanges ( { } , 'dblclick #3' ) )
317318
318319 // 1D zoombox - use the linked subplots
319320 . then ( doDrag ( 'xy2' , 'nsew' , - 100 , 0 ) )
320- . then ( checkRanges ( { xaxis : [ 0 , 1 ] } ) )
321+ . then ( checkRanges ( { xaxis : [ 0 , 1 ] } , 'xy2 zoombox' ) )
321322 . then ( doDrag ( 'x2y' , 'nsew' , 0 , 50 ) )
322- . then ( checkRanges ( { xaxis : [ 0 , 1 ] , yaxis : [ 0.5 , 1 ] } ) )
323+ . then ( checkRanges ( { xaxis : [ 0 , 1 ] , yaxis : [ 0.5 , 1 ] } , 'x2y zoombox' ) )
323324 // dblclick on linked subplots just changes the linked axis
324325 . then ( doDblClick ( 'xy2' , 'nsew' ) )
325- . then ( checkRanges ( { yaxis : [ 0.5 , 1 ] } ) )
326+ . then ( checkRanges ( { yaxis : [ 0.5 , 1 ] } , 'dblclick xy2' ) )
326327 . then ( doDblClick ( 'x2y' , 'nsew' ) )
327- . then ( checkRanges ( ) )
328+ . then ( checkRanges ( { } , 'dblclick x2y' ) )
328329 // drag on axis ends - all these 1D draggers the opposite axis delta is irrelevant
329330 . then ( doDrag ( 'xy2' , 'n' , 53 , 100 ) )
330- . then ( checkRanges ( { yaxis2 : [ 0 , 4 ] } ) )
331+ . then ( checkRanges ( { yaxis2 : [ 0 , 4 ] } , 'drag y2n' ) )
331332 . then ( doDrag ( 'xy' , 's' , 53 , - 100 ) )
332- . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] } ) )
333+ . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] } , 'drag ys' ) )
333334 // expanding drag is highly nonlinear
334335 . then ( doDrag ( 'x2y' , 'e' , 50 , 53 ) )
335- . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] , xaxis2 : [ 0 , 0.8751 ] } ) )
336+ . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] , xaxis2 : [ 0 , 0.8751 ] } , 'drag x2e' ) )
336337 . then ( doDrag ( 'x2y' , 'w' , - 50 , 53 ) )
337- . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] , xaxis2 : [ 0.4922 , 0.8751 ] } ) )
338+ . then ( checkRanges ( { yaxis : [ - 2 , 2 ] , yaxis2 : [ 0 , 4 ] , xaxis2 : [ 0.4922 , 0.8751 ] } , 'drag x2w' ) )
338339 // reset all from the modebar
339340 . then ( function ( ) { selectButton ( gd . _fullLayout . _modeBar , 'resetScale2d' ) . click ( ) ; } )
340- . then ( checkRanges ( ) )
341+ . then ( checkRanges ( { } , 'final reset' ) )
341342 . catch ( failTest )
342343 . then ( done ) ;
343344 } ) ;
@@ -346,42 +347,42 @@ describe('axis zoom/pan and main plot zoom', function() {
346347 makePlot ( )
347348 // drag axis middles
348349 . then ( doDrag ( 'x3y3' , 'ew' , 100 , 0 ) )
349- . then ( checkRanges ( { xaxis3 : [ - 1 , 1 ] } ) )
350+ . then ( checkRanges ( { xaxis3 : [ - 1 , 1 ] } , 'drag x3ew' ) )
350351 . then ( doDrag ( 'x3y3' , 'ns' , 53 , 100 ) )
351- . then ( checkRanges ( { xaxis3 : [ - 1 , 1 ] , yaxis3 : [ 1 , 3 ] } ) )
352+ . then ( checkRanges ( { xaxis3 : [ - 1 , 1 ] , yaxis3 : [ 1 , 3 ] } , 'drag y3ns' ) )
352353 // drag corners
353354 . then ( doDrag ( 'x3y3' , 'ne' , - 100 , 100 ) )
354- . then ( checkRanges ( { xaxis3 : [ - 1 , 3 ] , yaxis3 : [ 1 , 5 ] } ) )
355+ . then ( checkRanges ( { xaxis3 : [ - 1 , 3 ] , yaxis3 : [ 1 , 5 ] } , 'zoom x3y3ne' ) )
355356 . then ( doDrag ( 'x3y3' , 'sw' , 100 , - 100 ) )
356- . then ( checkRanges ( { xaxis3 : [ - 5 , 3 ] , yaxis3 : [ - 3 , 5 ] } ) )
357+ . then ( checkRanges ( { xaxis3 : [ - 5 , 3 ] , yaxis3 : [ - 3 , 5 ] } , 'zoom x3y3sw' ) )
357358 . then ( doDrag ( 'x3y3' , 'nw' , - 50 , - 50 ) )
358- . then ( checkRanges ( { xaxis3 : [ - 0.5006 , 3 ] , yaxis3 : [ - 3 , 0.5006 ] } ) )
359+ . then ( checkRanges ( { xaxis3 : [ - 0.5006 , 3 ] , yaxis3 : [ - 3 , 0.5006 ] } , 'zoom x3y3nw' ) )
359360 . then ( doDrag ( 'x3y3' , 'se' , 50 , 50 ) )
360- . then ( checkRanges ( { xaxis3 : [ - 0.5006 , 1.0312 ] , yaxis3 : [ - 1.0312 , 0.5006 ] } ) )
361+ . then ( checkRanges ( { xaxis3 : [ - 0.5006 , 1.0312 ] , yaxis3 : [ - 1.0312 , 0.5006 ] } , 'zoom x3y3se' ) )
361362 . then ( doDblClick ( 'x3y3' , 'nsew' ) )
362- . then ( checkRanges ( ) )
363+ . then ( checkRanges ( { } , 'reset x3y3' ) )
363364 // scroll wheel
364365 . then ( function ( ) {
365366 var mainDrag = getDragger ( 'xy' , 'nsew' ) ;
366367 var mainDragCoords = getNodeCoords ( mainDrag , 'se' ) ;
367368 mouseEvent ( 'scroll' , mainDragCoords . x , mainDragCoords . y , { deltaY : 20 , element : mainDrag } ) ;
368369 } )
369370 . then ( delay ( constants . REDRAWDELAY + 10 ) )
370- . then ( checkRanges ( { xaxis : [ - 0.4428 , 2 ] , yaxis : [ 0 , 2.4428 ] } ) )
371+ . then ( checkRanges ( { xaxis : [ - 0.4428 , 2 ] , yaxis : [ 0 , 2.4428 ] } , 'xy main scroll' ) )
371372 . then ( function ( ) {
372373 var ewDrag = getDragger ( 'xy' , 'ew' ) ;
373374 var ewDragCoords = getNodeCoords ( ewDrag ) ;
374375 mouseEvent ( 'scroll' , ewDragCoords . x - 50 , ewDragCoords . y , { deltaY : - 20 , element : ewDrag } ) ;
375376 } )
376377 . then ( delay ( constants . REDRAWDELAY + 10 ) )
377- . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0 , 2.4428 ] } ) )
378+ . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0 , 2.4428 ] } , 'x scroll' ) )
378379 . then ( function ( ) {
379380 var nsDrag = getDragger ( 'xy' , 'ns' ) ;
380381 var nsDragCoords = getNodeCoords ( nsDrag ) ;
381382 mouseEvent ( 'scroll' , nsDragCoords . x , nsDragCoords . y - 50 , { deltaY : - 20 , element : nsDrag } ) ;
382383 } )
383384 . then ( delay ( constants . REDRAWDELAY + 10 ) )
384- . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0.3321 , 2.3321 ] } ) )
385+ . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0.3321 , 2.3321 ] } , 'y scroll' ) )
385386 . catch ( failTest )
386387 . then ( done ) ;
387388 } ) ;
@@ -390,44 +391,45 @@ describe('axis zoom/pan and main plot zoom', function() {
390391 makePlot ( true )
391392 // zoombox - this *would* be 1D (dy=-1) but that's not allowed
392393 . then ( doDrag ( 'xy' , 'nsew' , 100 , - 1 ) )
393- . then ( checkRanges ( { xaxis : [ 1 , 2 ] , yaxis : [ 1 , 2 ] , xaxis2 : [ 0.5 , 1.5 ] , yaxis2 : [ 0.5 , 1.5 ] } ) )
394+ . then ( checkRanges ( { xaxis : [ 1 , 2 ] , yaxis : [ 1 , 2 ] , xaxis2 : [ 0.5 , 1.5 ] , yaxis2 : [ 0.5 , 1.5 ] } , 'zoombox xy' ) )
394395 // first dblclick reverts to saved ranges
395396 . then ( doDblClick ( 'xy' , 'nsew' ) )
396- . then ( checkRanges ( ) )
397+ . then ( checkRanges ( { } , 'dblclick xy' ) )
397398 // next dblclick autoscales ALL linked plots
398399 . then ( doDblClick ( 'xy' , 'ns' ) )
399- . then ( checkRanges ( { xaxis : autoRange , yaxis : autoRange , xaxis2 : autoRange , yaxis2 : autoRange } ) )
400+ . then ( checkRanges ( { xaxis : autoRange , yaxis : autoRange , xaxis2 : autoRange , yaxis2 : autoRange } , 'dblclick y' ) )
400401 // revert again
401402 . then ( doDblClick ( 'xy' , 'nsew' ) )
402- . then ( checkRanges ( ) )
403+ . then ( checkRanges ( { } , 'dblclick xy #2' ) )
403404 // corner drag - full distance in one direction and no shift in the other gets averaged
404405 // into half distance in each
405406 . then ( doDrag ( 'xy' , 'ne' , - 200 , 0 ) )
406- . then ( checkRanges ( { xaxis : [ 0 , 4 ] , yaxis : [ 0 , 4 ] , xaxis2 : [ - 1 , 3 ] , yaxis2 : [ - 1 , 3 ] } ) )
407+ . then ( checkRanges ( { xaxis : [ 0 , 4 ] , yaxis : [ 0 , 4 ] , xaxis2 : [ - 1 , 3 ] , yaxis2 : [ - 1 , 3 ] } , 'zoom xy ne' ) )
407408 // drag one end
408409 . then ( doDrag ( 'xy' , 's' , 53 , - 100 ) )
409- . then ( checkRanges ( { xaxis : [ - 2 , 6 ] , yaxis : [ - 4 , 4 ] , xaxis2 : [ - 3 , 5 ] , yaxis2 : [ - 3 , 5 ] } ) )
410+ . then ( checkRanges ( { xaxis : [ - 2 , 6 ] , yaxis : [ - 4 , 4 ] , xaxis2 : [ - 3 , 5 ] , yaxis2 : [ - 3 , 5 ] } , 'zoom y s' ) )
410411 // middle of an axis
411412 . then ( doDrag ( 'xy' , 'ew' , - 100 , 53 ) )
412- . then ( checkRanges ( { xaxis : [ 2 , 10 ] , yaxis : [ - 4 , 4 ] , xaxis2 : [ - 3 , 5 ] , yaxis2 : [ - 3 , 5 ] } ) )
413+ . then ( checkRanges ( { xaxis : [ 2 , 10 ] , yaxis : [ - 4 , 4 ] , xaxis2 : [ - 3 , 5 ] , yaxis2 : [ - 3 , 5 ] } , 'drag x ew' ) )
413414 // revert again
414415 . then ( doDblClick ( 'xy' , 'nsew' ) )
415- . then ( checkRanges ( ) )
416+ . then ( checkRanges ( { } , 'dblclick xy #3' ) )
416417 // scroll wheel
417418 . then ( function ( ) {
418419 var mainDrag = getDragger ( 'xy' , 'nsew' ) ;
419420 var mainDragCoords = getNodeCoords ( mainDrag , 'se' ) ;
420421 mouseEvent ( 'scroll' , mainDragCoords . x , mainDragCoords . y , { deltaY : 20 , element : mainDrag } ) ;
421422 } )
422423 . then ( delay ( constants . REDRAWDELAY + 10 ) )
423- . then ( checkRanges ( { xaxis : [ - 0.4428 , 2 ] , yaxis : [ 0 , 2.4428 ] , xaxis2 : [ - 0.2214 , 2.2214 ] , yaxis2 : [ - 0.2214 , 2.2214 ] } ) )
424+ . then ( checkRanges ( { xaxis : [ - 0.4428 , 2 ] , yaxis : [ 0 , 2.4428 ] , xaxis2 : [ - 0.2214 , 2.2214 ] , yaxis2 : [ - 0.2214 , 2.2214 ] } ,
425+ 'scroll xy' ) )
424426 . then ( function ( ) {
425427 var ewDrag = getDragger ( 'xy' , 'ew' ) ;
426428 var ewDragCoords = getNodeCoords ( ewDrag ) ;
427429 mouseEvent ( 'scroll' , ewDragCoords . x - 50 , ewDragCoords . y , { deltaY : - 20 , element : ewDrag } ) ;
428430 } )
429431 . then ( delay ( constants . REDRAWDELAY + 10 ) )
430- . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0.2214 , 2.2214 ] } ) )
432+ . then ( checkRanges ( { xaxis : [ - 0.3321 , 1.6679 ] , yaxis : [ 0.2214 , 2.2214 ] } , 'scroll x' ) )
431433 . catch ( failTest )
432434 . then ( done ) ;
433435 } ) ;
0 commit comments