@@ -13,6 +13,7 @@ var customMatchers = require('../assets/custom_matchers');
13
13
14
14
var MAPBOX_ACCESS_TOKEN = require ( '@build/credentials.json' ) . MAPBOX_ACCESS_TOKEN ;
15
15
var TRANSITION_DELAY = 500 ;
16
+ var MOUSE_DELAY = 100 ;
16
17
17
18
var noop = function ( ) { } ;
18
19
@@ -187,6 +188,22 @@ describe('mapbox credentials', function() {
187
188
mapboxAccessToken : dummyToken
188
189
} ) . catch ( function ( err ) {
189
190
expect ( err ) . toEqual ( new Error ( constants . mapOnErrorMsg ) ) ;
191
+ } ) . then ( done ) ;
192
+ } ) ;
193
+
194
+ it ( 'should use access token in mapbox layout options if present' , function ( done ) {
195
+ Plotly . plot ( gd , [ {
196
+ type : 'scattermapbox' ,
197
+ lon : [ 10 , 20 , 30 ] ,
198
+ lat : [ 10 , 20 , 30 ]
199
+ } ] , {
200
+ mapbox : {
201
+ accesstoken : MAPBOX_ACCESS_TOKEN
202
+ }
203
+ } , {
204
+ mapboxAccessToken : dummyToken
205
+ } ) . then ( function ( ) {
206
+ expect ( gd . _fullLayout . mapbox . accesstoken ) . toEqual ( MAPBOX_ACCESS_TOKEN ) ;
190
207
done ( ) ;
191
208
} ) ;
192
209
} ) ;
@@ -475,6 +492,22 @@ describe('mapbox plots', function() {
475
492
} ) ;
476
493
} ) ;
477
494
495
+ it ( 'should be able to update the access token' , function ( done ) {
496
+ var promise = Plotly . relayout ( gd , 'mapbox.accesstoken' , 'wont-work' ) ;
497
+
498
+ promise . catch ( function ( err ) {
499
+ expect ( gd . _fullLayout . mapbox . accesstoken ) . toEqual ( 'wont-work' ) ;
500
+ expect ( err ) . toEqual ( new Error ( constants . mapOnErrorMsg ) ) ;
501
+ } ) ;
502
+
503
+ promise . then ( function ( ) {
504
+ return Plotly . relayout ( gd , 'mapbox.accesstoken' , MAPBOX_ACCESS_TOKEN ) ;
505
+ } ) . then ( function ( ) {
506
+ expect ( gd . _fullLayout . mapbox . accesstoken ) . toEqual ( MAPBOX_ACCESS_TOKEN ) ;
507
+ } ) . then ( done ) ;
508
+ } ) ;
509
+
510
+
478
511
it ( 'should be able to update traces' , function ( done ) {
479
512
function assertDataPts ( lengths ) {
480
513
var lines = getGeoJsonData ( gd , 'lines' ) ,
@@ -763,15 +796,13 @@ describe('mapbox plots', function() {
763
796
}
764
797
765
798
function _mouseEvent ( type , pos , cb ) {
766
- var DELAY = 100 ;
767
-
768
799
return new Promise ( function ( resolve ) {
769
800
mouseEvent ( type , pos [ 0 ] , pos [ 1 ] ) ;
770
801
771
802
setTimeout ( function ( ) {
772
803
cb ( ) ;
773
804
resolve ( ) ;
774
- } , DELAY ) ;
805
+ } , MOUSE_DELAY ) ;
775
806
} ) ;
776
807
}
777
808
0 commit comments