@@ -23,7 +23,6 @@ Plotly.setPlotConfig({
23
23
mapboxAccessToken : MAPBOX_ACCESS_TOKEN
24
24
} ) ;
25
25
26
-
27
26
describe ( 'mapbox defaults' , function ( ) {
28
27
'use strict' ;
29
28
@@ -788,31 +787,19 @@ describe('@noCI, mapbox plots', function() {
788
787
. then ( done ) ;
789
788
} , LONG_TIMEOUT_INTERVAL ) ;
790
789
791
- it ( 'should respond drag / scroll interactions' , function ( done ) {
792
- var relayoutCnt = 0 ,
793
- updateData ;
790
+ it ( 'should respond drag / scroll / double-click interactions' , function ( done ) {
791
+ var relayoutCnt = 0 ;
792
+ var doubleClickCnt = 0 ;
793
+ var updateData ;
794
794
795
795
gd . on ( 'plotly_relayout' , function ( eventData ) {
796
796
relayoutCnt ++ ;
797
797
updateData = eventData ;
798
798
} ) ;
799
799
800
- function _drag ( p0 , p1 , cb ) {
801
- var promise = _mouseEvent ( 'mousemove' , p0 , noop ) . then ( function ( ) {
802
- return _mouseEvent ( 'mousedown' , p0 , noop ) ;
803
- } ) . then ( function ( ) {
804
- return _mouseEvent ( 'mousemove' , p1 , noop ) ;
805
- } ) . then ( function ( ) {
806
- // repeat mousemove to simulate long dragging motion
807
- return _mouseEvent ( 'mousemove' , p1 , noop ) ;
808
- } ) . then ( function ( ) {
809
- return _mouseEvent ( 'mouseup' , p1 , noop ) ;
810
- } ) . then ( function ( ) {
811
- return _mouseEvent ( 'mouseup' , p1 , noop ) ;
812
- } ) . then ( cb ) ;
813
-
814
- return promise ;
815
- }
800
+ gd . on ( 'plotly_doubleclick' , function ( ) {
801
+ doubleClickCnt ++ ;
802
+ } ) ;
816
803
817
804
function assertLayout ( center , zoom , opts ) {
818
805
var mapInfo = getMapInfo ( gd ) ,
@@ -838,8 +825,13 @@ describe('@noCI, mapbox plots', function() {
838
825
839
826
_drag ( pointPos , p1 , function ( ) {
840
827
expect ( relayoutCnt ) . toEqual ( 1 ) ;
841
- assertLayout ( [ - 19.651 , 13.751 ] , 1.234 , { withUpdateData : true } ) ;
828
+ assertLayout ( [ - 19.651 , 13.751 ] , 1.234 , { withUpdateData : true } ) ;
842
829
830
+ return _doubleClick ( p1 ) ;
831
+ } )
832
+ . then ( function ( ) {
833
+ expect ( doubleClickCnt ) . toBe ( 1 , 'double click cnt' ) ;
834
+ assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
843
835
} )
844
836
. catch ( failTest )
845
837
. then ( done ) ;
@@ -855,16 +847,6 @@ describe('@noCI, mapbox plots', function() {
855
847
ptData = eventData . points [ 0 ] ;
856
848
} ) ;
857
849
858
- function _click ( pos , cb ) {
859
- var promise = _mouseEvent ( 'mousemove' , pos , noop ) . then ( function ( ) {
860
- return _mouseEvent ( 'mousedown' , pos , noop ) ;
861
- } ) . then ( function ( ) {
862
- return _mouseEvent ( 'click' , pos , cb ) ;
863
- } ) ;
864
-
865
- return promise ;
866
- }
867
-
868
850
_click ( blankPos , function ( ) {
869
851
expect ( ptData ) . toBe ( undefined , 'not firing on blank points' ) ;
870
852
} )
@@ -991,6 +973,38 @@ describe('@noCI, mapbox plots', function() {
991
973
} , MOUSE_DELAY ) ;
992
974
} ) ;
993
975
}
976
+
977
+ function _click ( pos , cb ) {
978
+ var promise = _mouseEvent ( 'mousemove' , pos , noop ) . then ( function ( ) {
979
+ return _mouseEvent ( 'mousedown' , pos , noop ) ;
980
+ } ) . then ( function ( ) {
981
+ return _mouseEvent ( 'click' , pos , cb ) ;
982
+ } ) ;
983
+
984
+ return promise ;
985
+ }
986
+
987
+ function _doubleClick ( pos ) {
988
+ return _mouseEvent ( 'dblclick' , pos , noop ) ;
989
+ }
990
+
991
+ function _drag ( p0 , p1 , cb ) {
992
+ var promise = _mouseEvent ( 'mousemove' , p0 , noop ) . then ( function ( ) {
993
+ return _mouseEvent ( 'mousedown' , p0 , noop ) ;
994
+ } ) . then ( function ( ) {
995
+ return _mouseEvent ( 'mousemove' , p1 , noop ) ;
996
+ } ) . then ( function ( ) {
997
+ // repeat mousemove to simulate long dragging motion
998
+ return _mouseEvent ( 'mousemove' , p1 , noop ) ;
999
+ } ) . then ( function ( ) {
1000
+ return _mouseEvent ( 'mouseup' , p1 , noop ) ;
1001
+ } ) . then ( function ( ) {
1002
+ return _mouseEvent ( 'mouseup' , p1 , noop ) ;
1003
+ } ) . then ( cb ) ;
1004
+
1005
+ return promise ;
1006
+ }
1007
+
994
1008
} ) ;
995
1009
996
1010
describe ( '@noCI, mapbox toImage' , function ( ) {
0 commit comments