@@ -13,6 +13,7 @@ var customMatchers = require('../assets/custom_matchers');
1313
1414var MAPBOX_ACCESS_TOKEN = require ( '@build/credentials.json' ) . MAPBOX_ACCESS_TOKEN ;
1515var TRANSITION_DELAY = 500 ;
16+ var MOUSE_DELAY = 100 ;
1617
1718var noop = function ( ) { } ;
1819
@@ -187,6 +188,22 @@ describe('mapbox credentials', function() {
187188 mapboxAccessToken : dummyToken
188189 } ) . catch ( function ( err ) {
189190 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 ) ;
190207 done ( ) ;
191208 } ) ;
192209 } ) ;
@@ -475,6 +492,22 @@ describe('mapbox plots', function() {
475492 } ) ;
476493 } ) ;
477494
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+
478511 it ( 'should be able to update traces' , function ( done ) {
479512 function assertDataPts ( lengths ) {
480513 var lines = getGeoJsonData ( gd , 'lines' ) ,
@@ -763,15 +796,13 @@ describe('mapbox plots', function() {
763796 }
764797
765798 function _mouseEvent ( type , pos , cb ) {
766- var DELAY = 100 ;
767-
768799 return new Promise ( function ( resolve ) {
769800 mouseEvent ( type , pos [ 0 ] , pos [ 1 ] ) ;
770801
771802 setTimeout ( function ( ) {
772803 cb ( ) ;
773804 resolve ( ) ;
774- } , DELAY ) ;
805+ } , MOUSE_DELAY ) ;
775806 } ) ;
776807 }
777808
0 commit comments