@@ -548,56 +548,77 @@ describe('mapbox plots', function() {
548
548
expect ( countVisibleLayers ( gd ) ) . toEqual ( 0 ) ;
549
549
550
550
Plotly . relayout ( gd , 'mapbox.layers[0]' , layer0 ) . then ( function ( ) {
551
+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 1 ) ;
551
552
expect ( countVisibleLayers ( gd ) ) . toEqual ( 1 ) ;
552
553
553
554
return Plotly . relayout ( gd , 'mapbox.layers[1]' , layer1 ) ;
554
- } ) . then ( function ( ) {
555
+ } )
556
+ . then ( function ( ) {
557
+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
555
558
expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
556
559
557
560
return Plotly . relayout ( gd , mapUpdate ) ;
558
- } ) . then ( function ( ) {
561
+ } )
562
+ . then ( function ( ) {
563
+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
559
564
expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
560
565
561
566
return Plotly . relayout ( gd , styleUpdate0 ) ;
562
- } ) . then ( function ( ) {
567
+ } )
568
+ . then ( function ( ) {
569
+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
563
570
expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
564
571
565
572
return assertLayerStyle ( gd , {
566
573
'fill-color' : [ 1 , 0 , 0 , 1 ] ,
567
574
'fill-outline-color' : [ 0 , 0 , 1 , 1 ] ,
568
575
'fill-opacity' : 0.3
569
576
} , 0 ) ;
570
- } ) . then ( function ( ) {
577
+ } )
578
+ . then ( function ( ) {
579
+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
571
580
expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
572
581
573
582
return Plotly . relayout ( gd , styleUpdate1 ) ;
574
- } ) . then ( function ( ) {
583
+ } )
584
+ . then ( function ( ) {
585
+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
575
586
expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
576
587
577
588
return assertLayerStyle ( gd , {
578
589
'line-width' : 3 ,
579
590
'line-color' : [ 0 , 0 , 1 , 1 ] ,
580
591
'line-opacity' : 0.6
581
592
} , 1 ) ;
582
- } ) . then ( function ( ) {
593
+ } )
594
+ . then ( function ( ) {
595
+ expect ( gd . layout . mapbox . layers . length ) . toEqual ( 2 ) ;
583
596
expect ( countVisibleLayers ( gd ) ) . toEqual ( 2 ) ;
584
597
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 ) ;
587
602
expect ( countVisibleLayers ( gd ) ) . toEqual ( 1 ) ;
588
603
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 ) ;
591
608
expect ( countVisibleLayers ( gd ) ) . toEqual ( 0 ) ;
592
609
593
610
return Plotly . relayout ( gd , 'mapbox.layers[0]' , { } ) ;
594
- } ) . then ( function ( ) {
611
+ } )
612
+ . then ( function ( ) {
613
+ expect ( gd . layout . mapbox . layers ) . toEqual ( [ ] ) ;
595
614
expect ( countVisibleLayers ( gd ) ) . toEqual ( 0 ) ;
596
615
597
616
// layer with no source are not drawn
598
617
599
618
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 ) ;
601
622
expect ( countVisibleLayers ( gd ) ) . toEqual ( 1 ) ;
602
623
603
624
done ( ) ;
0 commit comments