@@ -12,7 +12,7 @@ var mouseEvent = require('../assets/mouse_event');
12
12
var customAssertions = require ( '../assets/custom_assertions' ) ;
13
13
var assertHoverLabelStyle = customAssertions . assertHoverLabelStyle ;
14
14
var assertHoverLabelContent = customAssertions . assertHoverLabelContent ;
15
- var fail = require ( '../assets/fail_test' ) ;
15
+ var failTest = require ( '../assets/fail_test' ) ;
16
16
var supplyAllDefaults = require ( '../assets/supply_defaults' ) ;
17
17
18
18
describe ( 'Test scattergeo defaults' , function ( ) {
@@ -252,7 +252,7 @@ describe('Test scattergeo hover', function() {
252
252
lat : [ 10 , 20 , 30 ] ,
253
253
text : [ 'A' , 'B' , 'C' ]
254
254
} ] )
255
- . catch ( fail )
255
+ . catch ( failTest )
256
256
. then ( done ) ;
257
257
} ) ;
258
258
@@ -287,31 +287,31 @@ describe('Test scattergeo hover', function() {
287
287
Plotly . restyle ( gd , 'hoverinfo' , 'lon+lat+text+name' ) . then ( function ( ) {
288
288
check ( [ 381 , 221 ] , [ '(10°, 10°)\nA' , 'trace 0' ] ) ;
289
289
} )
290
- . catch ( fail )
290
+ . catch ( failTest )
291
291
. then ( done ) ;
292
292
} ) ;
293
293
294
294
it ( 'should generate hover label info (\'text\' single value case)' , function ( done ) {
295
295
Plotly . restyle ( gd , 'text' , 'text' ) . then ( function ( ) {
296
296
check ( [ 381 , 221 ] , [ '(10°, 10°)\ntext' , null ] ) ;
297
297
} )
298
- . catch ( fail )
298
+ . catch ( failTest )
299
299
. then ( done ) ;
300
300
} ) ;
301
301
302
302
it ( 'should generate hover label info (\'hovertext\' single value case)' , function ( done ) {
303
303
Plotly . restyle ( gd , 'hovertext' , 'hovertext' ) . then ( function ( ) {
304
304
check ( [ 381 , 221 ] , [ '(10°, 10°)\nhovertext' , null ] ) ;
305
305
} )
306
- . catch ( fail )
306
+ . catch ( failTest )
307
307
. then ( done ) ;
308
308
} ) ;
309
309
310
310
it ( 'should generate hover label info (\'hovertext\' array case)' , function ( done ) {
311
311
Plotly . restyle ( gd , 'hovertext' , [ 'Apple' , 'Banana' , 'Orange' ] ) . then ( function ( ) {
312
312
check ( [ 381 , 221 ] , [ '(10°, 10°)\nApple' , null ] ) ;
313
313
} )
314
- . catch ( fail )
314
+ . catch ( failTest )
315
315
. then ( done ) ;
316
316
} ) ;
317
317
@@ -329,20 +329,20 @@ describe('Test scattergeo hover', function() {
329
329
fontFamily : 'Arial'
330
330
} ) ;
331
331
} )
332
- . catch ( fail )
332
+ . catch ( failTest )
333
333
. then ( done ) ;
334
334
} ) ;
335
335
336
336
it ( 'should generate hover label with arrayOk \'hoverinfo\' settings' , function ( done ) {
337
337
Plotly . restyle ( gd , 'hoverinfo' , [ [ 'lon' , null , 'lat+name' ] ] ) . then ( function ( ) {
338
338
check ( [ 381 , 221 ] , [ 'lon: 10°' , null ] ) ;
339
339
} )
340
- . catch ( fail )
340
+ . catch ( failTest )
341
341
. then ( done ) ;
342
342
} ) ;
343
343
} ) ;
344
344
345
- describe ( 'scattergeo bad data ' , function ( ) {
345
+ describe ( 'scattergeo drawing ' , function ( ) {
346
346
var gd ;
347
347
348
348
beforeEach ( function ( ) {
@@ -362,7 +362,33 @@ describe('scattergeo bad data', function() {
362
362
// only utopia logs - others are silently ignored
363
363
expect ( Lib . log ) . toHaveBeenCalledTimes ( 1 ) ;
364
364
} )
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 )
366
392
. then ( done ) ;
367
393
} ) ;
368
394
} ) ;
0 commit comments