@@ -295,9 +295,10 @@ describe('mapbox plots', function() {
295295 } ) . then ( function ( ) {
296296 expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 2 ) ;
297297
298- mock . data [ 0 ] . visible = false ;
298+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
299+ mockCopy . data [ 0 ] . visible = false ;
299300
300- return Plotly . newPlot ( gd , mock . data , mock . layout ) ;
301+ return Plotly . newPlot ( gd , mockCopy . data , mockCopy . layout ) ;
301302 } ) . then ( function ( ) {
302303 expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 1 ) ;
303304
@@ -344,6 +345,17 @@ describe('mapbox plots', function() {
344345 } ) ;
345346
346347 it ( 'should be able to restyle' , function ( done ) {
348+ var restyleCnt = 0 ,
349+ relayoutCnt = 0 ;
350+
351+ gd . on ( 'plotly_restyle' , function ( ) {
352+ restyleCnt ++ ;
353+ } ) ;
354+
355+ gd . on ( 'plotly_relayout' , function ( ) {
356+ relayoutCnt ++ ;
357+ } ) ;
358+
347359 function assertMarkerColor ( expectations ) {
348360 return new Promise ( function ( resolve ) {
349361 setTimeout ( function ( ) {
@@ -366,6 +378,9 @@ describe('mapbox plots', function() {
366378 return Plotly . restyle ( gd , 'marker.color' , 'green' ) ;
367379 } )
368380 . then ( function ( ) {
381+ expect ( restyleCnt ) . toEqual ( 1 ) ;
382+ expect ( relayoutCnt ) . toEqual ( 0 ) ;
383+
369384 return assertMarkerColor ( [
370385 [ 0 , 0.5019 , 0 , 1 ] ,
371386 [ 0 , 0.5019 , 0 , 1 ]
@@ -375,6 +390,9 @@ describe('mapbox plots', function() {
375390 return Plotly . restyle ( gd , 'marker.color' , 'red' , [ 1 ] ) ;
376391 } )
377392 . then ( function ( ) {
393+ expect ( restyleCnt ) . toEqual ( 2 ) ;
394+ expect ( relayoutCnt ) . toEqual ( 0 ) ;
395+
378396 return assertMarkerColor ( [
379397 [ 0 , 0.5019 , 0 , 1 ] ,
380398 [ 1 , 0 , 0 , 1 ]
@@ -384,6 +402,17 @@ describe('mapbox plots', function() {
384402 } ) ;
385403
386404 it ( 'should be able to relayout' , function ( done ) {
405+ var restyleCnt = 0 ,
406+ relayoutCnt = 0 ;
407+
408+ gd . on ( 'plotly_restyle' , function ( ) {
409+ restyleCnt ++ ;
410+ } ) ;
411+
412+ gd . on ( 'plotly_relayout' , function ( ) {
413+ relayoutCnt ++ ;
414+ } ) ;
415+
387416 function assertLayout ( style , center , zoom , dims ) {
388417 var mapInfo = getMapInfo ( gd ) ;
389418
@@ -403,22 +432,37 @@ describe('mapbox plots', function() {
403432 assertLayout ( 'Mapbox Dark' , [ - 4.710 , 19.475 ] , 1.234 , [ 80 , 100 , 908 , 270 ] ) ;
404433
405434 Plotly . relayout ( gd , 'mapbox.center' , { lon : 0 , lat : 0 } ) . then ( function ( ) {
435+ expect ( restyleCnt ) . toEqual ( 0 ) ;
436+ expect ( relayoutCnt ) . toEqual ( 1 ) ;
437+
406438 assertLayout ( 'Mapbox Dark' , [ 0 , 0 ] , 1.234 , [ 80 , 100 , 908 , 270 ] ) ;
407439
408440 return Plotly . relayout ( gd , 'mapbox.zoom' , '6' ) ;
409441 } ) . then ( function ( ) {
442+ expect ( restyleCnt ) . toEqual ( 0 ) ;
443+ expect ( relayoutCnt ) . toEqual ( 2 ) ;
444+
410445 assertLayout ( 'Mapbox Dark' , [ 0 , 0 ] , 6 , [ 80 , 100 , 908 , 270 ] ) ;
411446
412447 return Plotly . relayout ( gd , 'mapbox.style' , 'light' ) ;
413448 } ) . then ( function ( ) {
449+ expect ( restyleCnt ) . toEqual ( 0 ) ;
450+ expect ( relayoutCnt ) . toEqual ( 3 ) ;
451+
414452 assertLayout ( 'Mapbox Light' , [ 0 , 0 ] , 6 , [ 80 , 100 , 908 , 270 ] ) ;
415453
416454 return Plotly . relayout ( gd , 'mapbox.domain.x' , [ 0 , 0.5 ] ) ;
417455 } ) . then ( function ( ) {
456+ expect ( restyleCnt ) . toEqual ( 0 ) ;
457+ expect ( relayoutCnt ) . toEqual ( 4 ) ;
458+
418459 assertLayout ( 'Mapbox Light' , [ 0 , 0 ] , 6 , [ 80 , 100 , 454 , 270 ] ) ;
419460
420461 return Plotly . relayout ( gd , 'mapbox.domain.y[0]' , 0.5 ) ;
421462 } ) . then ( function ( ) {
463+ expect ( restyleCnt ) . toEqual ( 0 ) ;
464+ expect ( relayoutCnt ) . toEqual ( 5 ) ;
465+
422466 assertLayout ( 'Mapbox Light' , [ 0 , 0 ] , 6 , [ 80 , 100 , 454 , 135 ] ) ;
423467
424468 done ( ) ;
@@ -652,9 +696,11 @@ describe('mapbox plots', function() {
652696 } ) ;
653697
654698 it ( 'should respond drag / scroll interactions' , function ( done ) {
655- var updateData ;
699+ var relayoutCnt = 0 ,
700+ updateData ;
656701
657702 gd . on ( 'plotly_relayout' , function ( eventData ) {
703+ relayoutCnt ++ ;
658704 updateData = eventData ;
659705 } ) ;
660706
@@ -663,6 +709,9 @@ describe('mapbox plots', function() {
663709 return _mouseEvent ( 'mousedown' , p0 , noop ) ;
664710 } ) . then ( function ( ) {
665711 return _mouseEvent ( 'mousemove' , p1 , noop ) ;
712+ } ) . then ( function ( ) {
713+ // repeat mousemove to simulate long dragging motion
714+ return _mouseEvent ( 'mousemove' , p1 , noop ) ;
666715 } ) . then ( function ( ) {
667716 return _mouseEvent ( 'mouseup' , p1 , noop ) ;
668717 } ) . then ( function ( ) {
@@ -695,6 +744,7 @@ describe('mapbox plots', function() {
695744 var p1 = [ pointPos [ 0 ] + 50 , pointPos [ 1 ] - 20 ] ;
696745
697746 _drag ( pointPos , p1 , function ( ) {
747+ expect ( relayoutCnt ) . toEqual ( 1 ) ;
698748 assertLayout ( [ - 19.651 , 13.751 ] , 1.234 , { withUpdateData : true } ) ;
699749
700750 } )
0 commit comments