@@ -887,11 +887,11 @@ describe('@noCI, mapbox plots', function() {
887887 it ( 'should respond drag / scroll / double-click interactions' , function ( done ) {
888888 var relayoutCnt = 0 ;
889889 var doubleClickCnt = 0 ;
890- var updateData ;
890+ var evtData ;
891891
892- gd . on ( 'plotly_relayout' , function ( eventData ) {
892+ gd . on ( 'plotly_relayout' , function ( d ) {
893893 relayoutCnt ++ ;
894- updateData = eventData ;
894+ evtData = d ;
895895 } ) ;
896896
897897 gd . on ( 'plotly_doubleclick' , function ( ) {
@@ -906,43 +906,46 @@ describe('@noCI, mapbox plots', function() {
906906 } ) ;
907907 }
908908
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 ;
912912
913913 expect ( [ mapInfo . center . lng , mapInfo . center . lat ] ) . toBeCloseToArray ( center ) ;
914914 expect ( mapInfo . zoom ) . toBeCloseTo ( zoom ) ;
915915
916916 expect ( [ layout . center . lon , layout . center . lat ] ) . toBeCloseToArray ( center ) ;
917917 expect ( layout . zoom ) . toBeCloseTo ( zoom ) ;
918+ }
918919
919- if ( opts && opts . withUpdateData ) {
920- var mapboxUpdate = updateData . mapbox ;
920+ function _assert ( center , zoom ) {
921+ _assertLayout ( center , zoom ) ;
921922
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 ) ;
925925 }
926926
927- assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
927+ _assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
928928
929929 var p1 = [ pointPos [ 0 ] + 50 , pointPos [ 1 ] - 20 ] ;
930930
931931 _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 ) ;
934935
935936 return _doubleClick ( p1 ) ;
936937 } )
937938 . then ( function ( ) {
939+ expect ( relayoutCnt ) . toBe ( 2 , 'relayout cnt' ) ;
938940 expect ( doubleClickCnt ) . toBe ( 1 , 'double click cnt' ) ;
939- assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
941+ _assert ( [ - 4.710 , 19.475 ] , 1.234 ) ;
940942
941943 return _scroll ( pointPos ) ;
942944 } )
943945 . then ( function ( ) {
946+ expect ( relayoutCnt ) . toBe ( 3 , 'relayout cnt' ) ;
947+ expect ( doubleClickCnt ) . toBe ( 1 , 'double click cnt' ) ;
944948 expect ( getMapInfo ( gd ) . zoom ) . toBeGreaterThan ( 1.234 ) ;
945- expect ( relayoutCnt ) . toBe ( 2 ) ;
946949 } )
947950 . catch ( failTest )
948951 . then ( done ) ;
0 commit comments