@@ -1338,18 +1338,58 @@ describe('Test geo interactions', function() {
13381338 . then ( done ) ;
13391339 } ) ;
13401340
1341- it ( 'should not make request for topojson when not needed' , function ( done ) {
1342- var gd = createGraphDiv ( ) ;
1343- var fig = Lib . extendDeep ( { } , require ( '@mocks/geo_skymap.json' ) ) ;
1341+ describe ( 'should not make request for topojson when not needed' , function ( ) {
1342+ var gd ;
13441343
1345- spyOn ( d3 , 'json' ) . and . callThrough ( ) ;
1344+ beforeEach ( function ( ) {
1345+ if ( window . PlotlyGeoAssets && window . PlotlyGeoAssets . topojson ) {
1346+ delete window . PlotlyGeoAssets . topojson . world_110m ;
1347+ }
1348+ gd = createGraphDiv ( ) ;
1349+ spyOn ( d3 , 'json' ) . and . callThrough ( ) ;
1350+ } ) ;
13461351
1347- Plotly . plot ( gd , fig )
1348- . then ( function ( ) {
1349- expect ( d3 . json ) . toHaveBeenCalledTimes ( 0 ) ;
1350- } )
1351- . catch ( failTest )
1352- . then ( done ) ;
1352+ function _assert ( cnt ) {
1353+ return function ( ) {
1354+ expect ( d3 . json ) . toHaveBeenCalledTimes ( cnt ) ;
1355+ } ;
1356+ }
1357+
1358+ it ( '- no base layers + lon/lat traces' , function ( done ) {
1359+ var fig = Lib . extendDeep ( { } , require ( '@mocks/geo_skymap.json' ) ) ;
1360+
1361+ Plotly . plot ( gd , fig )
1362+ . then ( _assert ( 0 ) )
1363+ . then ( function ( ) { return Plotly . relayout ( gd , 'geo.showcoastlines' , true ) ; } )
1364+ . then ( _assert ( 1 ) )
1365+ . catch ( failTest )
1366+ . then ( done ) ;
1367+ } ) ;
1368+
1369+ it ( '- no base layers + choropleth' , function ( done ) {
1370+ Plotly . plot ( gd , [ {
1371+ type : 'choropleth' ,
1372+ locations : [ 'CAN' ] ,
1373+ z : [ 10 ]
1374+ } ] , {
1375+ geo : { showcoastlines : false }
1376+ } )
1377+ . then ( _assert ( 1 ) )
1378+ . catch ( failTest )
1379+ . then ( done ) ;
1380+ } ) ;
1381+
1382+ it ( '- no base layers + location scattergeo' , function ( done ) {
1383+ Plotly . plot ( gd , [ {
1384+ type : 'scattergeo' ,
1385+ locations : [ 'CAN' ] ,
1386+ } ] , {
1387+ geo : { showcoastlines : false }
1388+ } )
1389+ . then ( _assert ( 1 ) )
1390+ . catch ( failTest )
1391+ . then ( done ) ;
1392+ } ) ;
13531393 } ) ;
13541394} ) ;
13551395
0 commit comments