@@ -12,7 +12,7 @@ var mouseEvent = require('../assets/mouse_event');
1212var customAssertions = require ( '../assets/custom_assertions' ) ;
1313var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
1414var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
15- var fail = require ( '../assets/fail_test' ) ;
15+ var failTest = require ( '../assets/fail_test' ) ;
1616var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
1717
1818describe ( 'Test scattergeo defaults' , function ( ) {
@@ -252,7 +252,7 @@ describe('Test scattergeo hover', function() {
252252 lat : [ 10 , 20 , 30 ] ,
253253 text : [ 'A' , 'B' , 'C' ]
254254 } ] )
255- . catch ( fail )
255+ . catch ( failTest )
256256 . then ( done ) ;
257257 } ) ;
258258
@@ -287,31 +287,31 @@ describe('Test scattergeo hover', function() {
287287 Plotly . restyle ( gd , 'hoverinfo' , 'lon+lat+text+name' ) . then ( function ( ) {
288288 check ( [ 381 , 221 ] , [ '(10°, 10°)\nA' , 'trace 0' ] ) ;
289289 } )
290- . catch ( fail )
290+ . catch ( failTest )
291291 . then ( done ) ;
292292 } ) ;
293293
294294 it ( 'should generate hover label info (\'text\' single value case)' , function ( done ) {
295295 Plotly . restyle ( gd , 'text' , 'text' ) . then ( function ( ) {
296296 check ( [ 381 , 221 ] , [ '(10°, 10°)\ntext' , null ] ) ;
297297 } )
298- . catch ( fail )
298+ . catch ( failTest )
299299 . then ( done ) ;
300300 } ) ;
301301
302302 it ( 'should generate hover label info (\'hovertext\' single value case)' , function ( done ) {
303303 Plotly . restyle ( gd , 'hovertext' , 'hovertext' ) . then ( function ( ) {
304304 check ( [ 381 , 221 ] , [ '(10°, 10°)\nhovertext' , null ] ) ;
305305 } )
306- . catch ( fail )
306+ . catch ( failTest )
307307 . then ( done ) ;
308308 } ) ;
309309
310310 it ( 'should generate hover label info (\'hovertext\' array case)' , function ( done ) {
311311 Plotly . restyle ( gd , 'hovertext' , [ 'Apple' , 'Banana' , 'Orange' ] ) . then ( function ( ) {
312312 check ( [ 381 , 221 ] , [ '(10°, 10°)\nApple' , null ] ) ;
313313 } )
314- . catch ( fail )
314+ . catch ( failTest )
315315 . then ( done ) ;
316316 } ) ;
317317
@@ -329,20 +329,20 @@ describe('Test scattergeo hover', function() {
329329 fontFamily : 'Arial'
330330 } ) ;
331331 } )
332- . catch ( fail )
332+ . catch ( failTest )
333333 . then ( done ) ;
334334 } ) ;
335335
336336 it ( 'should generate hover label with arrayOk \'hoverinfo\' settings' , function ( done ) {
337337 Plotly . restyle ( gd , 'hoverinfo' , [ [ 'lon' , null , 'lat+name' ] ] ) . then ( function ( ) {
338338 check ( [ 381 , 221 ] , [ 'lon: 10°' , null ] ) ;
339339 } )
340- . catch ( fail )
340+ . catch ( failTest )
341341 . then ( done ) ;
342342 } ) ;
343343} ) ;
344344
345- describe ( 'scattergeo bad data ' , function ( ) {
345+ describe ( 'scattergeo drawing ' , function ( ) {
346346 var gd ;
347347
348348 beforeEach ( function ( ) {
@@ -362,7 +362,33 @@ describe('scattergeo bad data', function() {
362362 // only utopia logs - others are silently ignored
363363 expect ( Lib . log ) . toHaveBeenCalledTimes ( 1 ) ;
364364 } )
365- . catch ( fail )
365+ . catch ( failTest )
366+ . then ( done ) ;
367+ } ) ;
368+
369+ it ( 'preserves order after hide/show' , function ( done ) {
370+ function getIndices ( ) {
371+ var out = [ ] ;
372+ d3 . selectAll ( '.scattergeo' ) . each ( function ( d ) { out . push ( d [ 0 ] . trace . index ) ; } ) ;
373+ return out ;
374+ }
375+
376+ Plotly . newPlot ( gd , [
377+ { type : 'scattergeo' , lon : [ 10 , 20 ] , lat : [ 10 , 20 ] } ,
378+ { type : 'scattergeo' , lon : [ 10 , 20 ] , lat : [ 10 , 20 ] }
379+ ] )
380+ . then ( function ( ) {
381+ expect ( getIndices ( ) ) . toEqual ( [ 0 , 1 ] ) ;
382+ return Plotly . restyle ( gd , 'visible' , false , [ 0 ] ) ;
383+ } )
384+ . then ( function ( ) {
385+ expect ( getIndices ( ) ) . toEqual ( [ 1 ] ) ;
386+ return Plotly . restyle ( gd , 'visible' , true , [ 0 ] ) ;
387+ } )
388+ . then ( function ( ) {
389+ expect ( getIndices ( ) ) . toEqual ( [ 0 , 1 ] ) ;
390+ } )
391+ . catch ( failTest )
366392 . then ( done ) ;
367393 } ) ;
368394} ) ;
0 commit comments