@@ -866,11 +866,11 @@ describe('@noCI, mapbox plots', function() {
866
866
it ( 'should respond drag / scroll / double-click interactions' , function ( done ) {
867
867
var relayoutCnt = 0 ;
868
868
var doubleClickCnt = 0 ;
869
- var updateData ;
869
+ var evtData ;
870
870
871
- gd . on ( 'plotly_relayout' , function ( eventData ) {
871
+ gd . on ( 'plotly_relayout' , function ( d ) {
872
872
relayoutCnt ++ ;
873
- updateData = eventData ;
873
+ evtData = d ;
874
874
} ) ;
875
875
876
876
gd . on ( 'plotly_doubleclick' , function ( ) {
@@ -885,42 +885,46 @@ describe('@noCI, mapbox plots', function() {
885
885
} ) ;
886
886
}
887
887
888
- function assertLayout ( center , zoom , opts ) {
889
- var mapInfo = getMapInfo ( gd ) ,
890
- layout = gd . layout . mapbox ;
888
+ function _assertLayout ( center , zoom ) {
889
+ var mapInfo = getMapInfo ( gd ) ;
890
+ var layout = gd . layout . mapbox ;
891
891
892
892
expect ( [ mapInfo . center . lng , mapInfo . center . lat ] ) . toBeCloseToArray ( center ) ;
893
893
expect ( mapInfo . zoom ) . toBeCloseTo ( zoom ) ;
894
894
895
895
expect ( [ layout . center . lon , layout . center . lat ] ) . toBeCloseToArray ( center ) ;
896
896
expect ( layout . zoom ) . toBeCloseTo ( zoom ) ;
897
+ }
897
898
898
- if ( opts && opts . withUpdateData ) {
899
+ function _assert ( center , zoom ) {
900
+ _assertLayout ( center , zoom ) ;
899
901
900
902
expect ( [ evtData [ 'mapbox.center' ] . lon , evtData [ 'mapbox.center' ] . lat ] ) . toBeCloseToArray ( center ) ;
901
903
expect ( evtData [ 'mapbox.zoom' ] ) . toBeCloseTo ( zoom ) ;
902
- }
903
904
}
904
905
905
- assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
906
+ _assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
906
907
907
908
var p1 = [ pointPos [ 0 ] + 50 , pointPos [ 1 ] - 20 ] ;
908
909
909
910
_drag ( pointPos , p1 , function ( ) {
910
- expect ( relayoutCnt ) . toEqual ( 1 ) ;
911
- assertLayout ( [ - 19.651 , 13.751 ] , 1.234 , { withUpdateData : true } ) ;
911
+ expect ( relayoutCnt ) . toBe ( 1 , 'relayout cnt' ) ;
912
+ expect ( doubleClickCnt ) . toBe ( 0 , 'double click cnt' ) ;
913
+ _assert ( [ - 19.651 , 13.751 ] , 1.234 ) ;
912
914
913
915
return _doubleClick ( p1 ) ;
914
916
} )
915
917
. then ( function ( ) {
918
+ expect ( relayoutCnt ) . toBe ( 2 , 'relayout cnt' ) ;
916
919
expect ( doubleClickCnt ) . toBe ( 1 , 'double click cnt' ) ;
917
- assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
920
+ _assert ( [ - 4.710 , 19.475 ] , 1.234 ) ;
918
921
919
922
return _scroll ( pointPos ) ;
920
923
} )
921
924
. then ( function ( ) {
925
+ expect ( relayoutCnt ) . toBe ( 3 , 'relayout cnt' ) ;
926
+ expect ( doubleClickCnt ) . toBe ( 1 , 'double click cnt' ) ;
922
927
expect ( getMapInfo ( gd ) . zoom ) . toBeGreaterThan ( 1.234 ) ;
923
- expect ( relayoutCnt ) . toBe ( 2 ) ;
924
928
} )
925
929
. catch ( failTest )
926
930
. then ( done ) ;
0 commit comments