@@ -576,6 +576,59 @@ describe('mapbox plots', function() {
576576 } ) ;
577577 } ) ;
578578
579+ it ( 'should respond drag / scroll interactions' , function ( done ) {
580+ var updateData ;
581+
582+ gd . on ( 'plotly_relayout' , function ( eventData ) {
583+ updateData = eventData ;
584+ } ) ;
585+
586+ function _drag ( p0 , p1 , cb ) {
587+ var promise = _mouseEvent ( 'mousemove' , p0 , noop ) . then ( function ( ) {
588+ return _mouseEvent ( 'mousedown' , p0 , noop ) ;
589+ } ) . then ( function ( ) {
590+ return _mouseEvent ( 'mousemove' , p1 , noop ) ;
591+ } ) . then ( function ( ) {
592+ return _mouseEvent ( 'mouseup' , p1 , noop ) ;
593+ } ) . then ( function ( ) {
594+ return _mouseEvent ( 'mouseup' , p1 , noop ) ;
595+ } ) . then ( cb ) ;
596+
597+ return promise ;
598+ }
599+
600+ function assertLayout ( center , zoom , opts ) {
601+ var mapInfo = getMapInfo ( gd ) ,
602+ layout = gd . layout . mapbox ;
603+
604+ expect ( [ mapInfo . center . lng , mapInfo . center . lat ] ) . toBeCloseToArray ( center ) ;
605+ expect ( mapInfo . zoom ) . toBeCloseTo ( zoom ) ;
606+
607+ expect ( [ layout . center . lon , layout . center . lat ] ) . toBeCloseToArray ( center ) ;
608+ expect ( layout . zoom ) . toBeCloseTo ( zoom ) ;
609+
610+ if ( opts && opts . withUpdateData ) {
611+ var mapboxUpdate = updateData . mapbox ;
612+
613+ expect ( [ mapboxUpdate . center . lon , mapboxUpdate . center . lat ] ) . toBeCloseToArray ( center ) ;
614+ expect ( mapboxUpdate . zoom ) . toBeCloseTo ( zoom ) ;
615+ }
616+ }
617+
618+ assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
619+
620+ var p1 = [ pointPos [ 0 ] + 50 , pointPos [ 1 ] - 20 ] ;
621+
622+ _drag ( pointPos , p1 , function ( ) {
623+ assertLayout ( [ - 19.651 , 13.751 ] , 1.234 , { withUpdateData : true } ) ;
624+
625+ } )
626+ . then ( done ) ;
627+
628+ // TODO test scroll
629+
630+ } ) ;
631+
579632 it ( 'should respond to click interactions by' , function ( done ) {
580633 var ptData ;
581634
@@ -610,45 +663,6 @@ describe('mapbox plots', function() {
610663 . then ( done ) ;
611664 } ) ;
612665
613- it ( 'should respond drag / scroll interactions' , function ( done ) {
614- function _drag ( p0 , p1 , cb ) {
615- var promise = _mouseEvent ( 'mousemove' , p0 , noop ) . then ( function ( ) {
616- return _mouseEvent ( 'mousedown' , p0 , noop ) ;
617- } ) . then ( function ( ) {
618- return _mouseEvent ( 'mousemove' , p1 , noop ) ;
619- } ) . then ( function ( ) {
620- return _mouseEvent ( 'mouseup' , p1 , cb ) ;
621- } ) ;
622-
623- return promise ;
624- }
625-
626- function assertLayout ( center , zoom ) {
627- var mapInfo = getMapInfo ( gd ) ,
628- layout = gd . layout . mapbox ;
629-
630- expect ( [ mapInfo . center . lng , mapInfo . center . lat ] )
631- . toBeCloseToArray ( center ) ;
632- expect ( mapInfo . zoom ) . toBeCloseTo ( zoom ) ;
633-
634- expect ( [ layout . center . lon , layout . center . lat ] )
635- . toBeCloseToArray ( center ) ;
636- expect ( layout . zoom ) . toBeCloseTo ( zoom ) ;
637- }
638-
639- assertLayout ( [ - 4.710 , 19.475 ] , 1.234 ) ;
640-
641- var p1 = [ pointPos [ 0 ] + 50 , pointPos [ 1 ] - 20 ] ;
642-
643- _drag ( pointPos , p1 , function ( ) {
644- assertLayout ( [ - 19.651 , 13.751 ] , 1.234 ) ;
645- } )
646- . then ( done ) ;
647-
648- // TODO test scroll
649-
650- } ) ;
651-
652666 function getMapInfo ( gd ) {
653667 var subplot = gd . _fullLayout . mapbox . _subplot ,
654668 map = subplot . map ;
0 commit comments