@@ -674,6 +674,56 @@ describe('@noCI, mapbox plots', function() {
674674 . then ( done ) ;
675675 } , LONG_TIMEOUT_INTERVAL ) ;
676676
677+ it ( 'should be able to react to layer changes' , function ( done ) {
678+ function makeFigure ( color ) {
679+ return {
680+ data : [ { type : 'scattermapbox' } ] ,
681+ layout : {
682+ mapbox : {
683+ layers : [ {
684+ color : color ,
685+ sourcetype : 'geojson' ,
686+ type : 'fill' ,
687+ source : {
688+ type : 'Feature' ,
689+ properties : { } ,
690+ geometry : {
691+ type : 'Polygon' ,
692+ coordinates : [ [
693+ [ 174.74475860595703 , - 36.86533886128865 ] ,
694+ [ 174.77737426757812 , - 36.86533886128865 ] ,
695+ [ 174.77737426757812 , - 36.84913134182603 ] ,
696+ [ 174.74475860595703 , - 36.84913134182603 ] ,
697+ [ 174.74475860595703 , - 36.86533886128865 ]
698+ ] ]
699+ }
700+ }
701+ } ]
702+ }
703+ }
704+ } ;
705+ }
706+
707+ function _assert ( color ) {
708+ var mapInfo = getMapInfo ( gd ) ;
709+ var layer = mapInfo . layers [ mapInfo . layoutLayers [ 0 ] ] ;
710+
711+ expect ( mapInfo . layoutLayers . length ) . toBe ( 1 , 'one layer' ) ;
712+ expect ( mapInfo . layoutSources . length ) . toBe ( 1 , 'one layer source' ) ;
713+ expect ( String ( layer . paint . _values [ 'fill-color' ] . value . value ) ) . toBe ( color , 'layer color' ) ;
714+ }
715+
716+ Plotly . react ( gd , makeFigure ( 'blue' ) ) . then ( function ( ) {
717+ _assert ( 'rgba(0,0,255,1)' ) ;
718+ return Plotly . react ( gd , makeFigure ( 'red' ) ) ;
719+ } )
720+ . then ( function ( ) {
721+ _assert ( 'rgba(255,0,0,1)' ) ;
722+ } )
723+ . catch ( failTest )
724+ . then ( done ) ;
725+ } , LONG_TIMEOUT_INTERVAL ) ;
726+
677727 it ( 'should be able to update the access token' , function ( done ) {
678728 Plotly . relayout ( gd , 'mapbox.accesstoken' , 'wont-work' ) . catch ( function ( err ) {
679729 expect ( gd . _fullLayout . mapbox . accesstoken ) . toEqual ( 'wont-work' ) ;
0 commit comments