@@ -632,59 +632,32 @@ describe('@noCI scattermapbox hover', function() {
632
632
633
633
describe ( '@noCI Test plotly events on a scattermapbox plot:' , function ( ) {
634
634
var mock = require ( '@mocks/mapbox_0.json' ) ;
635
+ var pointPos = [ 440 , 290 ] ;
636
+ var nearPos = [ 460 , 290 ] ;
637
+ var blankPos = [ 10 , 10 ] ;
638
+ var mockCopy ;
639
+ var gd ;
635
640
636
- var mockCopy , gd ;
637
-
638
- var blankPos = [ 10 , 10 ] ,
639
- pointPos ,
640
- nearPos ;
641
-
642
- function getPointData ( gd ) {
643
- var cd = gd . calcdata ,
644
- mapbox = gd . _fullLayout . mapbox . _subplot ;
645
-
646
- return {
647
- index : false ,
648
- distance : 20 ,
649
- cd : cd [ 0 ] ,
650
- trace : cd [ 0 ] [ 0 ] . trace ,
651
- xa : mapbox . xaxis ,
652
- ya : mapbox . yaxis
653
- } ;
654
- }
655
-
656
- beforeAll ( function ( done ) {
641
+ beforeAll ( function ( ) {
657
642
Plotly . setPlotConfig ( {
658
643
mapboxAccessToken : require ( '@build/credentials.json' ) . MAPBOX_ACCESS_TOKEN
659
644
} ) ;
660
-
661
- gd = createGraphDiv ( ) ;
662
- mockCopy = Lib . extendDeep ( { } , mock ) ;
663
-
664
- Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( function ( ) {
665
- var bb = gd . _fullLayout . mapbox . _subplot . div . getBoundingClientRect ( ) ,
666
- xval = 10 ,
667
- yval = 10 ,
668
- point = ScatterMapbox . hoverPoints ( getPointData ( gd ) , xval , yval ) [ 0 ] ;
669
- pointPos = [ Math . floor ( bb . left + ( point . x0 + point . x1 ) / 2 ) ,
670
- Math . floor ( bb . top + ( point . y0 + point . y1 ) / 2 ) ] ;
671
- nearPos = [ pointPos [ 0 ] - 30 , pointPos [ 1 ] - 30 ] ;
672
- } ) . then ( destroyGraphDiv ) . then ( done ) ;
673
645
} ) ;
674
646
675
- beforeEach ( function ( ) {
647
+ beforeEach ( function ( done ) {
676
648
gd = createGraphDiv ( ) ;
677
649
mockCopy = Lib . extendDeep ( { } , mock ) ;
650
+ mockCopy . layout . width = 800 ;
651
+ mockCopy . layout . height = 500 ;
652
+ Plotly . plot ( gd , mockCopy ) . then ( done ) ;
678
653
} ) ;
679
654
680
655
afterEach ( destroyGraphDiv ) ;
681
656
682
657
describe ( 'click events' , function ( ) {
683
658
var futureData ;
684
659
685
- beforeEach ( function ( done ) {
686
- Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
687
-
660
+ beforeEach ( function ( ) {
688
661
futureData = undefined ;
689
662
gd . on ( 'plotly_click' , function ( data ) {
690
663
futureData = data ;
@@ -720,16 +693,15 @@ describe('@noCI Test plotly events on a scattermapbox plot:', function() {
720
693
721
694
describe ( 'modified click events' , function ( ) {
722
695
var clickOpts = {
723
- altKey : true ,
724
- ctrlKey : true ,
725
- metaKey : true ,
726
- shiftKey : true
727
- } ,
728
- futureData ;
696
+ altKey : true ,
697
+ ctrlKey : true ,
698
+ metaKey : true ,
699
+ shiftKey : true
700
+ } ;
729
701
730
- beforeEach ( function ( done ) {
731
- Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
702
+ var futureData ;
732
703
704
+ beforeEach ( function ( ) {
733
705
futureData = undefined ;
734
706
gd . on ( 'plotly_click' , function ( data ) {
735
707
futureData = data ;
@@ -774,9 +746,7 @@ describe('@noCI Test plotly events on a scattermapbox plot:', function() {
774
746
describe ( 'hover events' , function ( ) {
775
747
var futureData ;
776
748
777
- beforeEach ( function ( done ) {
778
- Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
779
-
749
+ beforeEach ( function ( ) {
780
750
gd . on ( 'plotly_hover' , function ( data ) {
781
751
futureData = data ;
782
752
} ) ;
@@ -786,8 +756,8 @@ describe('@noCI Test plotly events on a scattermapbox plot:', function() {
786
756
mouseEvent ( 'mousemove' , blankPos [ 0 ] , blankPos [ 1 ] ) ;
787
757
mouseEvent ( 'mousemove' , pointPos [ 0 ] , pointPos [ 1 ] ) ;
788
758
789
- var pt = futureData . points [ 0 ] ,
790
- evt = futureData . event ;
759
+ var pt = futureData . points [ 0 ] ;
760
+ var evt = futureData . event ;
791
761
792
762
expect ( Object . keys ( pt ) ) . toEqual ( [
793
763
'data' , 'fullData' , 'curveNumber' , 'pointNumber' , 'pointIndex' , 'lon' , 'lat'
@@ -808,18 +778,16 @@ describe('@noCI Test plotly events on a scattermapbox plot:', function() {
808
778
describe ( 'unhover events' , function ( ) {
809
779
var futureData ;
810
780
811
- beforeEach ( function ( done ) {
812
- Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
813
-
781
+ beforeEach ( function ( ) {
814
782
gd . on ( 'plotly_unhover' , function ( data ) {
815
783
futureData = data ;
816
784
} ) ;
817
785
} ) ;
818
786
819
787
it ( 'should contain the correct fields' , function ( done ) {
820
788
move ( pointPos [ 0 ] , pointPos [ 1 ] , nearPos [ 0 ] , nearPos [ 1 ] , HOVERMINTIME + 10 ) . then ( function ( ) {
821
- var pt = futureData . points [ 0 ] ,
822
- evt = futureData . event ;
789
+ var pt = futureData . points [ 0 ] ;
790
+ var evt = futureData . event ;
823
791
824
792
expect ( Object . keys ( pt ) ) . toEqual ( [
825
793
'data' , 'fullData' , 'curveNumber' , 'pointNumber' , 'pointIndex' , 'lon' , 'lat'
0 commit comments