@@ -14,6 +14,7 @@ var customMatchers = require('../assets/custom_matchers');
14
14
var MAPBOX_ACCESS_TOKEN = require ( '@build/credentials.json' ) . MAPBOX_ACCESS_TOKEN ;
15
15
var TRANSITION_DELAY = 500 ;
16
16
var MOUSE_DELAY = 100 ;
17
+ var LONG_TIMEOUT_INTERVAL = 5 * jasmine . DEFAULT_TIMEOUT_INTERVAL ;
17
18
18
19
var noop = function ( ) { } ;
19
20
@@ -204,7 +205,7 @@ describe('mapbox credentials', function() {
204
205
lat : [ 10 , 20 , 30 ]
205
206
} ] ) ;
206
207
} ) . toThrow ( new Error ( constants . noAccessTokenErrorMsg ) ) ;
207
- } ) ;
208
+ } , LONG_TIMEOUT_INTERVAL ) ;
208
209
209
210
it ( 'should throw error if token is invalid' , function ( done ) {
210
211
var cnt = 0 ;
@@ -215,14 +216,16 @@ describe('mapbox credentials', function() {
215
216
lat : [ 10 , 20 , 30 ]
216
217
} ] , { } , {
217
218
mapboxAccessToken : dummyToken
218
- } ) . catch ( function ( err ) {
219
+ } )
220
+ . catch ( function ( err ) {
219
221
cnt ++ ;
220
222
expect ( err ) . toEqual ( new Error ( constants . mapOnErrorMsg ) ) ;
221
- } ) . then ( function ( ) {
223
+ } )
224
+ . then ( function ( ) {
222
225
expect ( cnt ) . toEqual ( 1 ) ;
223
226
done ( ) ;
224
227
} ) ;
225
- } ) ;
228
+ } , LONG_TIMEOUT_INTERVAL ) ;
226
229
227
230
it ( 'should use access token in mapbox layout options if present' , function ( done ) {
228
231
var cnt = 0 ;
@@ -244,7 +247,7 @@ describe('mapbox credentials', function() {
244
247
expect ( gd . _fullLayout . mapbox . accesstoken ) . toEqual ( MAPBOX_ACCESS_TOKEN ) ;
245
248
done ( ) ;
246
249
} ) ;
247
- } ) ;
250
+ } , LONG_TIMEOUT_INTERVAL ) ;
248
251
249
252
it ( 'should bypass access token in mapbox layout options when config points to an Atlas server' , function ( done ) {
250
253
var cnt = 0 ;
@@ -263,14 +266,16 @@ describe('mapbox credentials', function() {
263
266
}
264
267
} , {
265
268
mapboxAccessToken : ''
266
- } ) . catch ( function ( err ) {
269
+ } )
270
+ . catch ( function ( err ) {
267
271
cnt ++ ;
268
272
expect ( err ) . toEqual ( new Error ( msg ) ) ;
269
- } ) . then ( function ( ) {
273
+ } )
274
+ . then ( function ( ) {
270
275
expect ( cnt ) . toEqual ( 1 ) ;
271
276
done ( ) ;
272
277
} ) ;
273
- } ) ;
278
+ } , LONG_TIMEOUT_INTERVAL ) ;
274
279
} ) ;
275
280
276
281
describe ( 'mapbox plots' , function ( ) {
@@ -310,27 +315,31 @@ describe('mapbox plots', function() {
310
315
expect ( gd . _fullLayout . mapbox ) . toBeUndefined ( ) ;
311
316
312
317
return Plotly . restyle ( gd , 'visible' , true ) ;
313
- } ) . then ( function ( ) {
318
+ } )
319
+ . then ( function ( ) {
314
320
expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 2 ) ;
315
321
316
322
return Plotly . restyle ( gd , 'visible' , 'legendonly' , [ 1 ] ) ;
317
- } ) . then ( function ( ) {
323
+ } )
324
+ . then ( function ( ) {
318
325
expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 1 ) ;
319
326
320
327
return Plotly . restyle ( gd , 'visible' , true ) ;
321
- } ) . then ( function ( ) {
328
+ } )
329
+ . then ( function ( ) {
322
330
expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 2 ) ;
323
331
324
332
var mockCopy = Lib . extendDeep ( { } , mock ) ;
325
333
mockCopy . data [ 0 ] . visible = false ;
326
334
327
335
return Plotly . newPlot ( gd , mockCopy . data , mockCopy . layout ) ;
328
- } ) . then ( function ( ) {
336
+ } )
337
+ . then ( function ( ) {
329
338
expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 1 ) ;
330
339
331
340
done ( ) ;
332
341
} ) ;
333
- } ) ;
342
+ } , LONG_TIMEOUT_INTERVAL ) ;
334
343
335
344
it ( 'should be able to delete and add traces' , function ( done ) {
336
345
var modes = [ 'line' , 'circle' ] ;
@@ -348,7 +357,8 @@ describe('mapbox plots', function() {
348
357
} ;
349
358
350
359
return Plotly . addTraces ( gd , [ trace ] ) ;
351
- } ) . then ( function ( ) {
360
+ } )
361
+ . then ( function ( ) {
352
362
expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 2 ) ;
353
363
354
364
var trace = {
@@ -359,16 +369,18 @@ describe('mapbox plots', function() {
359
369
} ;
360
370
361
371
return Plotly . addTraces ( gd , [ trace ] ) ;
362
- } ) . then ( function ( ) {
372
+ } )
373
+ . then ( function ( ) {
363
374
expect ( countVisibleTraces ( gd , modes ) ) . toEqual ( 3 ) ;
364
375
365
376
return Plotly . deleteTraces ( gd , [ 0 , 1 , 2 ] ) ;
366
- } ) . then ( function ( ) {
377
+ } )
378
+ . then ( function ( ) {
367
379
expect ( gd . _fullLayout . mapbox ) . toBeUndefined ( ) ;
368
380
369
381
done ( ) ;
370
382
} ) ;
371
- } ) ;
383
+ } , LONG_TIMEOUT_INTERVAL ) ;
372
384
373
385
it ( 'should be able to restyle' , function ( done ) {
374
386
var restyleCnt = 0 ,
@@ -425,7 +437,7 @@ describe('mapbox plots', function() {
425
437
] ) ;
426
438
} )
427
439
. then ( done ) ;
428
- } ) ;
440
+ } , LONG_TIMEOUT_INTERVAL ) ;
429
441
430
442
it ( 'should be able to relayout' , function ( done ) {
431
443
var restyleCnt = 0 ,
@@ -462,36 +474,40 @@ describe('mapbox plots', function() {
462
474
assertLayout ( 'Mapbox Dark' , [ 0 , 0 ] , 1.234 , [ 80 , 100 , 908 , 270 ] ) ;
463
475
464
476
return Plotly . relayout ( gd , 'mapbox.zoom' , '6' ) ;
465
- } ) . then ( function ( ) {
477
+ } )
478
+ . then ( function ( ) {
466
479
expect ( restyleCnt ) . toEqual ( 0 ) ;
467
480
expect ( relayoutCnt ) . toEqual ( 2 ) ;
468
481
469
482
assertLayout ( 'Mapbox Dark' , [ 0 , 0 ] , 6 , [ 80 , 100 , 908 , 270 ] ) ;
470
483
471
484
return Plotly . relayout ( gd , 'mapbox.style' , 'light' ) ;
472
- } ) . then ( function ( ) {
485
+ } )
486
+ . then ( function ( ) {
473
487
expect ( restyleCnt ) . toEqual ( 0 ) ;
474
488
expect ( relayoutCnt ) . toEqual ( 3 ) ;
475
489
476
490
assertLayout ( 'Mapbox Light' , [ 0 , 0 ] , 6 , [ 80 , 100 , 908 , 270 ] ) ;
477
491
478
492
return Plotly . relayout ( gd , 'mapbox.domain.x' , [ 0 , 0.5 ] ) ;
479
- } ) . then ( function ( ) {
493
+ } )
494
+ . then ( function ( ) {
480
495
expect ( restyleCnt ) . toEqual ( 0 ) ;
481
496
expect ( relayoutCnt ) . toEqual ( 4 ) ;
482
497
483
498
assertLayout ( 'Mapbox Light' , [ 0 , 0 ] , 6 , [ 80 , 100 , 454 , 270 ] ) ;
484
499
485
500
return Plotly . relayout ( gd , 'mapbox.domain.y[0]' , 0.5 ) ;
486
- } ) . then ( function ( ) {
501
+ } )
502
+ . then ( function ( ) {
487
503
expect ( restyleCnt ) . toEqual ( 0 ) ;
488
504
expect ( relayoutCnt ) . toEqual ( 5 ) ;
489
505
490
506
assertLayout ( 'Mapbox Light' , [ 0 , 0 ] , 6 , [ 80 , 100 , 454 , 135 ] ) ;
491
507
492
508
done ( ) ;
493
509
} ) ;
494
- } ) ;
510
+ } , LONG_TIMEOUT_INTERVAL ) ;
495
511
496
512
it ( 'should be able to add, update and remove layers' , function ( done ) {
497
513
var mockWithLayers = require ( '@mocks/mapbox_layers' ) ;
@@ -623,7 +639,7 @@ describe('mapbox plots', function() {
623
639
624
640
done ( ) ;
625
641
} ) ;
626
- } ) ;
642
+ } , LONG_TIMEOUT_INTERVAL ) ;
627
643
628
644
it ( 'should be able to update the access token' , function ( done ) {
629
645
Plotly . relayout ( gd , 'mapbox.accesstoken' , 'wont-work' ) . catch ( function ( err ) {
@@ -637,7 +653,7 @@ describe('mapbox plots', function() {
637
653
expect ( gd . _promises . length ) . toEqual ( 0 ) ;
638
654
done ( ) ;
639
655
} ) ;
640
- } ) ;
656
+ } , LONG_TIMEOUT_INTERVAL ) ;
641
657
642
658
it ( 'should be able to update traces' , function ( done ) {
643
659
function assertDataPts ( lengths ) {
@@ -669,12 +685,13 @@ describe('mapbox plots', function() {
669
685
} ;
670
686
671
687
return Plotly . extendTraces ( gd , update , [ 0 , 1 ] ) ;
672
- } ) . then ( function ( ) {
688
+ } )
689
+ . then ( function ( ) {
673
690
assertDataPts ( [ 5 , 5 ] ) ;
674
691
675
692
done ( ) ;
676
693
} ) ;
677
- } ) ;
694
+ } , LONG_TIMEOUT_INTERVAL ) ;
678
695
679
696
it ( 'should display to hover labels on mouse over' , function ( done ) {
680
697
function assertMouseMove ( pos , len ) {
@@ -688,7 +705,7 @@ describe('mapbox plots', function() {
688
705
assertMouseMove ( blankPos , 0 ) . then ( function ( ) {
689
706
return assertMouseMove ( pointPos , 1 ) ;
690
707
} ) . then ( done ) ;
691
- } ) ;
708
+ } , LONG_TIMEOUT_INTERVAL ) ;
692
709
693
710
it ( 'should respond to hover interactions by' , function ( done ) {
694
711
var hoverCnt = 0 ,
@@ -736,7 +753,7 @@ describe('mapbox plots', function() {
736
753
737
754
done ( ) ;
738
755
} ) ;
739
- } ) ;
756
+ } , LONG_TIMEOUT_INTERVAL ) ;
740
757
741
758
it ( 'should respond drag / scroll interactions' , function ( done ) {
742
759
var relayoutCnt = 0 ,
@@ -795,7 +812,7 @@ describe('mapbox plots', function() {
795
812
796
813
// TODO test scroll
797
814
798
- } ) ;
815
+ } , LONG_TIMEOUT_INTERVAL ) ;
799
816
800
817
it ( 'should respond to click interactions by' , function ( done ) {
801
818
var ptData ;
@@ -828,7 +845,7 @@ describe('mapbox plots', function() {
828
845
} ) ;
829
846
} )
830
847
. then ( done ) ;
831
- } ) ;
848
+ } , LONG_TIMEOUT_INTERVAL ) ;
832
849
833
850
function getMapInfo ( gd ) {
834
851
var subplot = gd . _fullLayout . mapbox . _subplot ,
0 commit comments