@@ -180,18 +180,26 @@ describe('mapbox credentials', function() {
180
180
} ) ;
181
181
182
182
it ( 'should throw error if token is invalid' , function ( done ) {
183
+ var cnt = 0 ;
184
+
183
185
Plotly . plot ( gd , [ {
184
186
type : 'scattermapbox' ,
185
187
lon : [ 10 , 20 , 30 ] ,
186
188
lat : [ 10 , 20 , 30 ]
187
189
} ] , { } , {
188
190
mapboxAccessToken : dummyToken
189
191
} ) . catch ( function ( err ) {
192
+ cnt ++ ;
190
193
expect ( err ) . toEqual ( new Error ( constants . mapOnErrorMsg ) ) ;
191
- } ) . then ( done ) ;
194
+ } ) . then ( function ( ) {
195
+ expect ( cnt ) . toEqual ( 1 ) ;
196
+ done ( ) ;
197
+ } ) ;
192
198
} ) ;
193
199
194
200
it ( 'should use access token in mapbox layout options if present' , function ( done ) {
201
+ var cnt = 0 ;
202
+
195
203
Plotly . plot ( gd , [ {
196
204
type : 'scattermapbox' ,
197
205
lon : [ 10 , 20 , 30 ] ,
@@ -202,7 +210,10 @@ describe('mapbox credentials', function() {
202
210
}
203
211
} , {
204
212
mapboxAccessToken : dummyToken
213
+ } ) . catch ( function ( ) {
214
+ cnt ++ ;
205
215
} ) . then ( function ( ) {
216
+ expect ( cnt ) . toEqual ( 0 ) ;
206
217
expect ( gd . _fullLayout . mapbox . accesstoken ) . toEqual ( MAPBOX_ACCESS_TOKEN ) ;
207
218
done ( ) ;
208
219
} ) ;
@@ -493,21 +504,19 @@ describe('mapbox plots', function() {
493
504
} ) ;
494
505
495
506
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 ) {
507
+ Plotly . relayout ( gd , 'mapbox.accesstoken' , 'wont-work' ) . catch ( function ( err ) {
499
508
expect ( gd . _fullLayout . mapbox . accesstoken ) . toEqual ( 'wont-work' ) ;
500
509
expect ( err ) . toEqual ( new Error ( constants . mapOnErrorMsg ) ) ;
501
- } ) ;
510
+ expect ( gd . _promises . length ) . toEqual ( 1 ) ;
502
511
503
- promise . then ( function ( ) {
504
512
return Plotly . relayout ( gd , 'mapbox.accesstoken' , MAPBOX_ACCESS_TOKEN ) ;
505
513
} ) . then ( function ( ) {
506
514
expect ( gd . _fullLayout . mapbox . accesstoken ) . toEqual ( MAPBOX_ACCESS_TOKEN ) ;
507
- } ) . then ( done ) ;
515
+ expect ( gd . _promises . length ) . toEqual ( 0 ) ;
516
+ done ( ) ;
517
+ } ) ;
508
518
} ) ;
509
519
510
-
511
520
it ( 'should be able to update traces' , function ( done ) {
512
521
function assertDataPts ( lengths ) {
513
522
var lines = getGeoJsonData ( gd , 'lines' ) ,
0 commit comments