@@ -2068,28 +2068,43 @@ describe('Test geo zoom/pan/drag interactions:', function() {
20682068 } ) ;
20692069
20702070 describe ( 'plotly_relayouting' , function ( ) {
2071- [ 'pan' , 'zoom' ] . forEach ( function ( dragmode ) {
2072- it ( 'should emit plotly_relayouting events on' , function ( done ) {
2073- var events = [ ] ; var path = [ [ 300 , 300 ] , [ 350 , 300 ] , [ 350 , 400 ] ] ; var relayoutCallback ;
2074- var fig = Lib . extendDeep ( { } , require ( '@mocks/geo_choropleth-usa' ) ) ;
2075- fig . layout . dragmode = dragmode ;
2076-
2077- gd = createGraphDiv ( ) ;
2078- Plotly . plot ( gd , fig )
2079- . then ( function ( ) {
2080- relayoutCallback = jasmine . createSpy ( 'relayoutCallback' ) ;
2081- gd . on ( 'plotly_relayout' , relayoutCallback ) ;
2082- gd . on ( 'plotly_relayouting' , function ( e ) {
2083- events . push ( e ) ;
2084- } ) ;
2085- return drag ( path ) ;
2086- } )
2087- . then ( function ( ) {
2088- expect ( events . length ) . toEqual ( path . length - 1 ) ;
2089- expect ( relayoutCallback ) . toHaveBeenCalledTimes ( 1 ) ;
2090- } )
2091- . catch ( failTest )
2092- . then ( done ) ;
2071+ var mocks = {
2072+ 'non-clipped' : require ( '@mocks/geo_winkel-tripel' ) ,
2073+ 'clipped' : require ( '@mocks/geo_orthographic' ) ,
2074+ 'scoped' : require ( '@mocks/geo_europe-bubbles' )
2075+ } ;
2076+ [ 'non-clipped' , 'clipped' , 'scoped' ] . forEach ( function ( zoomHandler ) {
2077+ [ 'pan' ] . forEach ( function ( dragmode ) {
2078+ it ( 'should emit events on ' + dragmode + ' for ' + zoomHandler , function ( done ) {
2079+ var events = [ ] ; var path = [ [ 300 , 300 ] , [ 350 , 300 ] , [ 350 , 400 ] ] ;
2080+ var relayoutCnt = 0 ; var relayoutEvent ;
2081+ var fig = Lib . extendDeep ( { } , mocks [ zoomHandler ] ) ;
2082+ fig . layout . dragmode = dragmode ;
2083+ fig . layout . width = 700 ;
2084+ fig . layout . height = 500 ;
2085+
2086+ gd = createGraphDiv ( ) ;
2087+ Plotly . plot ( gd , fig )
2088+ . then ( function ( ) {
2089+ gd . on ( 'plotly_relayout' , function ( e ) {
2090+ relayoutCnt ++ ;
2091+ relayoutEvent = e ;
2092+ } ) ;
2093+ gd . on ( 'plotly_relayouting' , function ( e ) {
2094+ events . push ( e ) ;
2095+ } ) ;
2096+ return drag ( path ) ;
2097+ } )
2098+ . then ( function ( ) {
2099+ expect ( events . length ) . toEqual ( path . length - 1 ) ;
2100+ expect ( relayoutCnt ) . toEqual ( 1 ) ;
2101+ Object . keys ( relayoutEvent ) . sort ( ) . forEach ( function ( key ) {
2102+ expect ( Object . keys ( events [ 0 ] ) ) . toContain ( key ) ;
2103+ } ) ;
2104+ } )
2105+ . catch ( failTest )
2106+ . then ( done ) ;
2107+ } ) ;
20932108 } ) ;
20942109 } ) ;
20952110 } ) ;
0 commit comments