@@ -887,11 +887,11 @@ describe('@noCI, mapbox plots', function() {
887
887
it ( 'should respond drag / scroll / double-click interactions' , function ( done ) {
888
888
var relayoutCnt = 0 ;
889
889
var doubleClickCnt = 0 ;
890
- var updateData ;
890
+ var evtData ;
891
891
892
- gd . on ( 'plotly_relayout' , function ( eventData ) {
892
+ gd . on ( 'plotly_relayout' , function ( d ) {
893
893
relayoutCnt ++ ;
894
- updateData = eventData ;
894
+ evtData = d ;
895
895
} ) ;
896
896
897
897
gd . on ( 'plotly_doubleclick' , function ( ) {
@@ -906,43 +906,46 @@ describe('@noCI, mapbox plots', function() {
906
906
} ) ;
907
907
}
908
908
909
- function assertLayout ( center , zoom , opts ) {
910
- var mapInfo = getMapInfo ( gd ) ,
911
- layout = gd . layout . mapbox ;
909
+ function _assertLayout ( center , zoom ) {
910
+ var mapInfo = getMapInfo ( gd ) ;
911
+ var layout = gd . layout . mapbox ;
912
912
913
913
expect ( [ mapInfo . center . lng , mapInfo . center . lat ] ) . toBeCloseToArray ( center ) ;
914
914
expect ( mapInfo . zoom ) . toBeCloseTo ( zoom ) ;
915
915
916
916
expect ( [ layout . center . lon , layout . center . lat ] ) . toBeCloseToArray ( center ) ;
917
917
expect ( layout . zoom ) . toBeCloseTo ( zoom ) ;
918
+ }
918
919
919
- if ( opts && opts . withUpdateData ) {
920
- var mapboxUpdate = updateData . mapbox ;
920
+ function _assert ( center , zoom ) {
921
+ _assertLayout ( center , zoom ) ;
921
922
922
- expect ( [ mapboxUpdate . center . lon , mapboxUpdate . center . lat ] ) . toBeCloseToArray ( center ) ;
923
- expect ( mapboxUpdate . zoom ) . toBeCloseTo ( zoom ) ;
924
- }
923
+ expect ( [ evtData [ 'mapbox.center' ] . lon , evtData [ 'mapbox.center' ] . lat ] ) . toBeCloseToArray ( center ) ;
924
+ expect ( evtData [ 'mapbox.zoom' ] ) . toBeCloseTo ( zoom ) ;
925
925
}
926
926
927
- assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
927
+ _assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
928
928
929
929
var p1 = [ pointPos [ 0 ] + 50 , pointPos [ 1 ] - 20 ] ;
930
930
931
931
_drag ( pointPos , p1 , function ( ) {
932
- expect ( relayoutCnt ) . toEqual ( 1 ) ;
933
- assertLayout ( [ - 19.651 , 13.751 ] , 1.234 , { withUpdateData : true } ) ;
932
+ expect ( relayoutCnt ) . toBe ( 1 , 'relayout cnt' ) ;
933
+ expect ( doubleClickCnt ) . toBe ( 0 , 'double click cnt' ) ;
934
+ _assert ( [ - 19.651 , 13.751 ] , 1.234 ) ;
934
935
935
936
return _doubleClick ( p1 ) ;
936
937
} )
937
938
. then ( function ( ) {
939
+ expect ( relayoutCnt ) . toBe ( 2 , 'relayout cnt' ) ;
938
940
expect ( doubleClickCnt ) . toBe ( 1 , 'double click cnt' ) ;
939
- assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
941
+ _assert ( [ - 4.710 , 19.475 ] , 1.234 ) ;
940
942
941
943
return _scroll ( pointPos ) ;
942
944
} )
943
945
. then ( function ( ) {
946
+ expect ( relayoutCnt ) . toBe ( 3 , 'relayout cnt' ) ;
947
+ expect ( doubleClickCnt ) . toBe ( 1 , 'double click cnt' ) ;
944
948
expect ( getMapInfo ( gd ) . zoom ) . toBeGreaterThan ( 1.234 ) ;
945
- expect ( relayoutCnt ) . toBe ( 2 ) ;
946
949
} )
947
950
. catch ( failTest )
948
951
. then ( done ) ;
0 commit comments