@@ -649,28 +649,8 @@ describe('Click-to-select', function() {
649
649
]
650
650
. forEach ( function ( testCase ) {
651
651
var ciAnnotation = testCase . gl ? 'gl' : 'flaky' ;
652
- it ( '@' + ciAnnotation + ' trace type ' + testCase . traceType , function ( done ) {
653
- var defaultLayoutOpts = {
654
- layout : {
655
- clickmode : 'event+select' ,
656
- dragmode : 'pan' ,
657
- hovermode : 'closest'
658
- }
659
- } ;
660
- var customLayoutOptions = {
661
- layout : testCase . layoutOptions
662
- } ;
663
- var customConfigOptions = {
664
- config : testCase . configOptions
665
- } ;
666
- var mockCopy = Lib . extendDeep (
667
- { } ,
668
- testCase . mock ,
669
- defaultLayoutOpts ,
670
- customLayoutOptions ,
671
- customConfigOptions ) ;
672
-
673
- Plotly . plot ( gd , mockCopy . data , mockCopy . layout , mockCopy . config )
652
+ it ( '@' + ciAnnotation + ' trace type ' + testCase . label , function ( done ) {
653
+ Plotly . plot ( gd , testCase . mock . data , testCase . mock . layout , testCase . mock . config )
674
654
. then ( function ( ) {
675
655
return _immediateClickPt ( testCase ) ;
676
656
} )
@@ -693,24 +673,78 @@ describe('Click-to-select', function() {
693
673
. then ( done ) ;
694
674
} ) ;
695
675
} ) ;
676
+ } ) ;
696
677
697
- function testCase ( traceType , mock , x , y , expectedPts , layoutOptions , configOptions ) {
698
- return {
699
- traceType : traceType ,
700
- mock : mock ,
701
- layoutOptions : layoutOptions ,
702
- x : x ,
703
- y : y ,
704
- expectedPts : expectedPts ,
705
- configOptions : configOptions ,
706
- gl : false ,
707
- enableGl : function ( ) {
708
- this . gl = true ;
709
- return this ;
710
- }
711
- } ;
712
- }
678
+ describe ( 'triggers \'plotly_selected\' before \'plotly_click\'' , function ( ) {
679
+ [
680
+ testCase ( 'cartesian' , require ( '@mocks/14.json' ) , 270 , 160 , [ 7 ] ) ,
681
+ testCase ( 'geo' , require ( '@mocks/geo_scattergeo-locations.json' ) , 285 , 240 , [ 1 ] ) ,
682
+ testCase ( 'ternary' , require ( '@mocks/ternary_markers.json' ) , 485 , 335 , [ 7 ] ) ,
683
+ testCase ( 'mapbox' , require ( '@mocks/mapbox_0.json' ) , 650 , 195 , [ [ 2 ] , [ ] ] , { } ,
684
+ { mapboxAccessToken : require ( '@build/credentials.json' ) . MAPBOX_ACCESS_TOKEN } ) ,
685
+ testCase ( 'polar' , require ( '@mocks/polar_scatter.json' ) , 130 , 290 ,
686
+ [ [ ] , [ ] , [ ] , [ 19 ] , [ ] , [ ] ] , { dragmode : 'zoom' } )
687
+ ] . forEach ( function ( testCase ) {
688
+ it ( '@flaky for base plot ' + testCase . label , function ( done ) {
689
+ Plotly . plot ( gd , testCase . mock . data , testCase . mock . layout , testCase . mock . config )
690
+ . then ( function ( ) {
691
+ var clickHandlerCalled = false ;
692
+ var selectedHandlerCalled = false ;
693
+
694
+ gd . on ( 'plotly_selected' , function ( ) {
695
+ expect ( clickHandlerCalled ) . toBe ( false ) ;
696
+ selectedHandlerCalled = true ;
697
+ } ) ;
698
+ gd . on ( 'plotly_click' , function ( ) {
699
+ clickHandlerCalled = true ;
700
+ expect ( selectedHandlerCalled ) . toBe ( true ) ;
701
+ done ( ) ;
702
+ } ) ;
703
+
704
+ return click ( testCase . x , testCase . y ) ;
705
+ } )
706
+ . catch ( failTest )
707
+ . then ( done ) ;
708
+ } ) ;
709
+ } ) ;
713
710
} ) ;
711
+
712
+ function testCase ( label , mock , x , y , expectedPts , layoutOptions , configOptions ) {
713
+ var defaultLayoutOpts = {
714
+ layout : {
715
+ clickmode : 'event+select' ,
716
+ dragmode : 'pan' ,
717
+ hovermode : 'closest'
718
+ }
719
+ } ;
720
+ var customLayoutOptions = {
721
+ layout : layoutOptions
722
+ } ;
723
+ var customConfigOptions = {
724
+ config : configOptions
725
+ } ;
726
+ var mockCopy = Lib . extendDeep (
727
+ { } ,
728
+ mock ,
729
+ defaultLayoutOpts ,
730
+ customLayoutOptions ,
731
+ customConfigOptions ) ;
732
+
733
+ return {
734
+ label : label ,
735
+ mock : mockCopy ,
736
+ layoutOptions : layoutOptions ,
737
+ x : x ,
738
+ y : y ,
739
+ expectedPts : expectedPts ,
740
+ configOptions : configOptions ,
741
+ gl : false ,
742
+ enableGl : function ( ) {
743
+ this . gl = true ;
744
+ return this ;
745
+ }
746
+ } ;
747
+ }
714
748
} ) ;
715
749
716
750
describe ( 'Test select box and lasso in general:' , function ( ) {
0 commit comments