@@ -295,6 +295,13 @@ describe('mapbox plots', function() {
295
295
} ) . then ( function ( ) {
296
296
expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 2 ) ;
297
297
298
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
299
+ mockCopy . data [ 0 ] . visible = false ;
300
+
301
+ return Plotly . newPlot ( gd , mockCopy . data , mockCopy . layout ) ;
302
+ } ) . then ( function ( ) {
303
+ expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 1 ) ;
304
+
298
305
done ( ) ;
299
306
} ) ;
300
307
} ) ;
@@ -338,6 +345,17 @@ describe('mapbox plots', function() {
338
345
} ) ;
339
346
340
347
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
+
341
359
function assertMarkerColor ( expectations ) {
342
360
return new Promise ( function ( resolve ) {
343
361
setTimeout ( function ( ) {
@@ -360,6 +378,9 @@ describe('mapbox plots', function() {
360
378
return Plotly . restyle ( gd , 'marker.color' , 'green' ) ;
361
379
} )
362
380
. then ( function ( ) {
381
+ expect ( restyleCnt ) . toEqual ( 1 ) ;
382
+ expect ( relayoutCnt ) . toEqual ( 0 ) ;
383
+
363
384
return assertMarkerColor ( [
364
385
[ 0 , 0.5019 , 0 , 1 ] ,
365
386
[ 0 , 0.5019 , 0 , 1 ]
@@ -369,6 +390,9 @@ describe('mapbox plots', function() {
369
390
return Plotly . restyle ( gd , 'marker.color' , 'red' , [ 1 ] ) ;
370
391
} )
371
392
. then ( function ( ) {
393
+ expect ( restyleCnt ) . toEqual ( 2 ) ;
394
+ expect ( relayoutCnt ) . toEqual ( 0 ) ;
395
+
372
396
return assertMarkerColor ( [
373
397
[ 0 , 0.5019 , 0 , 1 ] ,
374
398
[ 1 , 0 , 0 , 1 ]
@@ -378,6 +402,17 @@ describe('mapbox plots', function() {
378
402
} ) ;
379
403
380
404
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
+
381
416
function assertLayout ( style , center , zoom , dims ) {
382
417
var mapInfo = getMapInfo ( gd ) ;
383
418
@@ -397,22 +432,37 @@ describe('mapbox plots', function() {
397
432
assertLayout ( 'Mapbox Dark' , [ - 4.710 , 19.475 ] , 1.234 , [ 80 , 100 , 908 , 270 ] ) ;
398
433
399
434
Plotly . relayout ( gd , 'mapbox.center' , { lon : 0 , lat : 0 } ) . then ( function ( ) {
435
+ expect ( restyleCnt ) . toEqual ( 0 ) ;
436
+ expect ( relayoutCnt ) . toEqual ( 1 ) ;
437
+
400
438
assertLayout ( 'Mapbox Dark' , [ 0 , 0 ] , 1.234 , [ 80 , 100 , 908 , 270 ] ) ;
401
439
402
440
return Plotly . relayout ( gd , 'mapbox.zoom' , '6' ) ;
403
441
} ) . then ( function ( ) {
442
+ expect ( restyleCnt ) . toEqual ( 0 ) ;
443
+ expect ( relayoutCnt ) . toEqual ( 2 ) ;
444
+
404
445
assertLayout ( 'Mapbox Dark' , [ 0 , 0 ] , 6 , [ 80 , 100 , 908 , 270 ] ) ;
405
446
406
447
return Plotly . relayout ( gd , 'mapbox.style' , 'light' ) ;
407
448
} ) . then ( function ( ) {
449
+ expect ( restyleCnt ) . toEqual ( 0 ) ;
450
+ expect ( relayoutCnt ) . toEqual ( 3 ) ;
451
+
408
452
assertLayout ( 'Mapbox Light' , [ 0 , 0 ] , 6 , [ 80 , 100 , 908 , 270 ] ) ;
409
453
410
454
return Plotly . relayout ( gd , 'mapbox.domain.x' , [ 0 , 0.5 ] ) ;
411
455
} ) . then ( function ( ) {
456
+ expect ( restyleCnt ) . toEqual ( 0 ) ;
457
+ expect ( relayoutCnt ) . toEqual ( 4 ) ;
458
+
412
459
assertLayout ( 'Mapbox Light' , [ 0 , 0 ] , 6 , [ 80 , 100 , 454 , 270 ] ) ;
413
460
414
461
return Plotly . relayout ( gd , 'mapbox.domain.y[0]' , 0.5 ) ;
415
462
} ) . then ( function ( ) {
463
+ expect ( restyleCnt ) . toEqual ( 0 ) ;
464
+ expect ( relayoutCnt ) . toEqual ( 5 ) ;
465
+
416
466
assertLayout ( 'Mapbox Light' , [ 0 , 0 ] , 6 , [ 80 , 100 , 454 , 135 ] ) ;
417
467
418
468
done ( ) ;
@@ -646,9 +696,11 @@ describe('mapbox plots', function() {
646
696
} ) ;
647
697
648
698
it ( 'should respond drag / scroll interactions' , function ( done ) {
649
- var updateData ;
699
+ var relayoutCnt = 0 ,
700
+ updateData ;
650
701
651
702
gd . on ( 'plotly_relayout' , function ( eventData ) {
703
+ relayoutCnt ++ ;
652
704
updateData = eventData ;
653
705
} ) ;
654
706
@@ -657,6 +709,9 @@ describe('mapbox plots', function() {
657
709
return _mouseEvent ( 'mousedown' , p0 , noop ) ;
658
710
} ) . then ( function ( ) {
659
711
return _mouseEvent ( 'mousemove' , p1 , noop ) ;
712
+ } ) . then ( function ( ) {
713
+ // repeat mousemove to simulate long dragging motion
714
+ return _mouseEvent ( 'mousemove' , p1 , noop ) ;
660
715
} ) . then ( function ( ) {
661
716
return _mouseEvent ( 'mouseup' , p1 , noop ) ;
662
717
} ) . then ( function ( ) {
@@ -689,6 +744,7 @@ describe('mapbox plots', function() {
689
744
var p1 = [ pointPos [ 0 ] + 50 , pointPos [ 1 ] - 20 ] ;
690
745
691
746
_drag ( pointPos , p1 , function ( ) {
747
+ expect ( relayoutCnt ) . toEqual ( 1 ) ;
692
748
assertLayout ( [ - 19.651 , 13.751 ] , 1.234 , { withUpdateData : true } ) ;
693
749
694
750
} )
0 commit comments