@@ -942,6 +942,80 @@ describe('@noCI, mapbox plots', function() {
942
942
. then ( done ) ;
943
943
} , LONG_TIMEOUT_INTERVAL ) ;
944
944
945
+ it ( '@gl should not wedge graph after reacting to invalid layer' , function ( done ) {
946
+ Plotly . react ( gd , [ { type : 'scattermapbox' } ] , {
947
+ mapbox : {
948
+ layers : [ { source : 'invalid' } ]
949
+ }
950
+ } )
951
+ . then ( function ( ) {
952
+ fail ( 'The above Plotly.react promise should be rejected' ) ;
953
+ } )
954
+ . catch ( function ( ) {
955
+ expect ( gd . _promises . length ) . toBe ( 1 , 'has 1 rejected promise in queue' ) ;
956
+ } )
957
+ . then ( function ( ) {
958
+ return Plotly . react ( gd , [ { type : 'scattermapbox' } ] , {
959
+ mapbox : {
960
+ layers : [ {
961
+ sourcetype : 'vector' ,
962
+ sourcelayer : 'contour' ,
963
+ source : 'mapbox://mapbox.mapbox-terrain-v2'
964
+ } ]
965
+ }
966
+ } ) ;
967
+ } )
968
+ . then ( function ( ) {
969
+ expect ( gd . _promises . length ) . toBe ( 0 , 'rejected promise has been cleared' ) ;
970
+
971
+ var mapInfo = getMapInfo ( gd ) ;
972
+ expect ( mapInfo . layoutLayers . length ) . toBe ( 1 , 'one layer' ) ;
973
+ expect ( mapInfo . layoutSources . length ) . toBe ( 1 , 'one layer source' ) ;
974
+ } )
975
+ . catch ( failTest )
976
+ . then ( done ) ;
977
+ } , LONG_TIMEOUT_INTERVAL ) ;
978
+
979
+ it ( '@gl should not attempt to remove non-existing layer sources' , function ( done ) {
980
+ function _assert ( msg , exp ) {
981
+ return function ( ) {
982
+ var layerList = gd . _fullLayout . mapbox . _subplot . layerList ;
983
+ expect ( layerList . length ) . toBe ( exp , msg ) ;
984
+ } ;
985
+ }
986
+
987
+ Plotly . react ( gd , [ { type : 'scattermapbox' } ] , {
988
+ mapbox : { layers : [ { } ] }
989
+ } )
990
+ . then ( _assert ( '1 visible:false layer' , 1 ) )
991
+ . then ( function ( ) {
992
+ return Plotly . react ( gd , [ { type : 'scattermapbox' } ] , {
993
+ mapbox : { layers : [ ] }
994
+ } ) ;
995
+ } )
996
+ . then ( _assert ( 'no layers' , 0 ) )
997
+ . catch ( failTest )
998
+ . then ( done ) ;
999
+ } , LONG_TIMEOUT_INTERVAL ) ;
1000
+
1001
+ it ( '@gl should validate layout layer input' , function ( done ) {
1002
+ Plotly . newPlot ( gd , [ { type : 'scattermapbox' } ] , {
1003
+ mapbox : {
1004
+ layers : [ {
1005
+ sourcetype : 'raster' ,
1006
+ source : [ '' ]
1007
+ } ]
1008
+ }
1009
+ } )
1010
+ . then ( function ( ) {
1011
+ var mapInfo = getMapInfo ( gd ) ;
1012
+ expect ( mapInfo . layoutLayers . length ) . toBe ( 0 , 'no on-map layer' ) ;
1013
+ expect ( mapInfo . layoutSources . length ) . toBe ( 0 , 'no map source' ) ;
1014
+ } )
1015
+ . catch ( failTest )
1016
+ . then ( done ) ;
1017
+ } , LONG_TIMEOUT_INTERVAL ) ;
1018
+
945
1019
it ( '@gl should be able to update the access token' , function ( done ) {
946
1020
Plotly . relayout ( gd , 'mapbox.accesstoken' , 'wont-work' ) . catch ( function ( err ) {
947
1021
expect ( gd . _fullLayout . mapbox . accesstoken ) . toEqual ( 'wont-work' ) ;
0 commit comments