@@ -935,6 +935,57 @@ describe('@noCI, mapbox plots', function() {
935935 . then ( done ) ;
936936 } , LONG_TIMEOUT_INTERVAL ) ;
937937
938+ it ( '@gl should be able to update layer image' , function ( done ) {
939+ var coords = [
940+ [ - 80.425 , 46.437 ] ,
941+ [ - 71.516 , 46.437 ] ,
942+ [ - 71.516 , 37.936 ] ,
943+ [ - 80.425 , 37.936 ]
944+ ] ;
945+ function makeFigure ( source ) {
946+ return {
947+ data : [ { type : 'scattermapbox' } ] ,
948+ layout : {
949+ mapbox : {
950+ layers : [ {
951+ 'sourcetype' : 'image' ,
952+ 'coordinates' : coords ,
953+ 'source' : source
954+ } ]
955+ }
956+ }
957+ } ;
958+ }
959+
960+ var map = null ;
961+ var layerSource = null ;
962+
963+ // Single pixel PNGs generated with http://png-pixel.com/
964+ var prefix = 'data:image/png;base64,' ;
965+ var redImage = prefix + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42m' +
966+ 'P8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==' ;
967+ var greenImage = prefix + 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42m' +
968+ 'Nk+M/wHwAEBgIApD5fRAAAAABJRU5ErkJggg==' ;
969+
970+ Plotly . react ( gd , makeFigure ( redImage ) ) . then ( function ( ) {
971+ var mapbox = gd . _fullLayout . mapbox . _subplot ;
972+ map = mapbox . map ;
973+ layerSource = map . getSource ( mapbox . layerList [ 0 ] . idSource ) ;
974+
975+ spyOn ( layerSource , 'updateImage' ) . and . callThrough ( ) ;
976+ spyOn ( map , 'removeSource' ) . and . callThrough ( ) ;
977+ return Plotly . react ( gd , makeFigure ( greenImage ) ) ;
978+ } )
979+ . then ( function ( ) {
980+ expect ( layerSource . updateImage ) . toHaveBeenCalledWith (
981+ { url : greenImage , coordinates : coords }
982+ ) ;
983+ expect ( map . removeSource ) . not . toHaveBeenCalled ( ) ;
984+ } )
985+ . catch ( failTest )
986+ . then ( done ) ;
987+ } , LONG_TIMEOUT_INTERVAL ) ;
988+
938989 it ( '@gl should be able to react to layer changes' , function ( done ) {
939990 function makeFigure ( color ) {
940991 return {
0 commit comments