@@ -548,56 +548,77 @@ describe('mapbox plots', function() {
548548 expect ( countVisibleLayers ( gd ) ) . toEqual ( 0 ) ;
549549
550550 Plotly . relayout ( gd , 'mapbox.layers[0]' , layer0 ) . then ( function ( ) {
551+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 1 ) ;
551552 expect ( countVisibleLayers ( gd ) ) . toEqual ( 1 ) ;
552553
553554 return Plotly . relayout ( gd , 'mapbox.layers[1]' , layer1 ) ;
554- } ) . then ( function ( ) {
555+ } )
556+ . then ( function ( ) {
557+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
555558 expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
556559
557560 return Plotly . relayout ( gd , mapUpdate ) ;
558- } ) . then ( function ( ) {
561+ } )
562+ . then ( function ( ) {
563+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
559564 expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
560565
561566 return Plotly . relayout ( gd , styleUpdate0 ) ;
562- } ) . then ( function ( ) {
567+ } )
568+ . then ( function ( ) {
569+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
563570 expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
564571
565572 return assertLayerStyle ( gd , {
566573 'fill-color' : [ 1 , 0 , 0 , 1 ] ,
567574 'fill-outline-color' : [ 0 , 0 , 1 , 1 ] ,
568575 'fill-opacity' : 0.3
569576 } , 0 ) ;
570- } ) . then ( function ( ) {
577+ } )
578+ . then ( function ( ) {
579+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
571580 expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
572581
573582 return Plotly . relayout ( gd , styleUpdate1 ) ;
574- } ) . then ( function ( ) {
583+ } )
584+ . then ( function ( ) {
585+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
575586 expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
576587
577588 return assertLayerStyle ( gd , {
578589 'line-width' : 3 ,
579590 'line-color' : [ 0 , 0 , 1 , 1 ] ,
580591 'line-opacity' : 0.6
581592 } , 1 ) ;
582- } ) . then ( function ( ) {
593+ } )
594+ . then ( function ( ) {
595+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
583596 expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
584597
585- return Plotly . relayout ( gd , 'mapbox.layers[1]' , 'remove' ) ;
586- } ) . then ( function ( ) {
598+ return Plotly . relayout ( gd , 'mapbox.layers[1]' , null ) ;
599+ } )
600+ . then ( function ( ) {
601+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 1 ) ;
587602 expect ( countVisibleLayers ( gd ) ) . toEqual ( 1 ) ;
588603
589- return Plotly . relayout ( gd , 'mapbox.layers[0]' , 'remove' ) ;
590- } ) . then ( function ( ) {
604+ return Plotly . relayout ( gd , 'mapbox.layers[0]' , null ) ;
605+ } )
606+ . then ( function ( ) {
607+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 0 ) ;
591608 expect ( countVisibleLayers ( gd ) ) . toEqual ( 0 ) ;
592609
593610 return Plotly . relayout ( gd , 'mapbox.layers[0]' , { } ) ;
594- } ) . then ( function ( ) {
611+ } )
612+ . then ( function ( ) {
613+ expect ( gd . layout . mapbox . layers ) . toEqual ( [ ] ) ;
595614 expect ( countVisibleLayers ( gd ) ) . toEqual ( 0 ) ;
596615
597616 // layer with no source are not drawn
598617
599618 return Plotly . relayout ( gd , 'mapbox.layers[0].source' , layer0 . source ) ;
600- } ) . then ( function ( ) {
619+ } )
620+ . then ( function ( ) {
621+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 1 ) ;
601622 expect ( countVisibleLayers ( gd ) ) . toEqual ( 1 ) ;
602623
603624 done ( ) ;
0 commit comments