@@ -767,7 +767,7 @@ describe('SourceListV3', () => {
767
767
id : 'sameBaseLayer' ,
768
768
layers : layers . slice ( 1 , 3 ) . map ( ( item ) => {
769
769
const nextItem = Object . assign ( { } , item ) ;
770
- nextItem . metadata = { SM_Layer_Id : 'sameBaseLayer' } ;
770
+ nextItem . metadata = { SM_Layer_Id : 'sameBaseLayer' , title : `custom_ ${ item . id } ` } ;
771
771
return nextItem ;
772
772
} ) ,
773
773
sources : {
@@ -790,9 +790,52 @@ describe('SourceListV3', () => {
790
790
appreciableLayers = sourceListModel . getLayers ( ) ;
791
791
expect ( layerList . length ) . toBe ( 3 ) ;
792
792
expect ( layerList [ layerList . length - 1 ] . id ) . toBe ( 'sameBaseLayer' ) ;
793
+ expect ( layerList [ layerList . length - 1 ] . children [ 0 ] . title . match ( / c u s t o m _ T I A N D I T U _ I M G _ 3 8 5 7 $ / ) ) . toBeTruthy ( ) ;
794
+ expect ( layerList [ layerList . length - 1 ] . children [ 1 ] . title . match ( / c u s t o m _ m s _ T I A N D I T U _ I M G _ 3 8 5 7 _ l a b e l $ / ) ) . toBeTruthy ( ) ;
793
795
expect ( appreciableLayers . length ) . toBe ( 5 ) ;
794
796
expect ( appreciableLayers [ 0 ] . id . match ( / T I A N D I T U _ I M G _ 3 8 5 7 _ T I A N D I T U _ I M G _ 3 8 5 7 _ \d + $ / ) ) . toBeTruthy ( ) ;
795
797
expect ( appreciableLayers [ 1 ] . id . match ( / m s _ T I A N D I T U _ I M G _ 3 8 5 7 _ l a b e l _ m s _ T I A N D I T U _ I M G _ 3 8 5 7 _ l a b e l _ \d + $ / ) ) . toBeTruthy ( ) ;
798
+ expect ( appreciableLayers [ 0 ] . title . match ( / c u s t o m _ T I A N D I T U _ I M G _ 3 8 5 7 / ) ) . toBeTruthy ( ) ;
799
+ expect ( appreciableLayers [ 1 ] . title . match ( / c u s t o m _ m s _ T I A N D I T U _ I M G _ 3 8 5 7 _ l a b e l / ) ) . toBeTruthy ( ) ;
800
+ done ( ) ;
801
+ } ) ;
802
+
803
+ it ( 'changeBaseLayer show title' , ( done ) => {
804
+ const nextBaseLayerMapInfo = cloneDeep ( changeBaseLayerMapInfo ) ;
805
+ layers = nextBaseLayerMapInfo . layers ;
806
+ sources = nextBaseLayerMapInfo . sources ;
807
+
808
+ overlayLayersManager = { } ;
809
+
810
+ const sourceListModel = new SourceListModelV3 ( {
811
+ map,
812
+ mapInfo : cloneDeep ( nextBaseLayerMapInfo ) ,
813
+ mapResourceInfo : { } ,
814
+ legendList : [ ] ,
815
+ l7LayerUtil : {
816
+ isL7Layer,
817
+ getL7MarkerLayers : ( ) => [ ]
818
+ }
819
+ } ) ;
820
+ expect ( map . getStyle ( ) . layers . some ( ( item ) => [ 'TIANDITU_IMG_3857' , 'ms_TIANDITU_IMG_3857_label' ] . includes ( item . id ) ) ) . toBeTruthy ( ) ;
821
+ const layerList = sourceListModel . getLayerCatalog ( ) ;
822
+ const appreciableLayers = sourceListModel . getLayers ( ) ;
823
+ expect ( layerList . length ) . toBe ( 2 ) ;
824
+ expect ( appreciableLayers . length ) . toBe ( 3 ) ;
825
+ const baseLayerInfoCopy = {
826
+ ...baseLayerInfo ,
827
+ layers : baseLayerInfo . layers . map ( ( item ) => ( {
828
+ ...item ,
829
+ metadata : { title : `custom_${ item . id } ` }
830
+ } ) )
831
+ } ;
832
+ const nextBaseLayerInfo = sourceListModel . changeBaseLayer ( baseLayerInfoCopy ) ;
833
+ expect ( nextBaseLayerInfo ) . toBeTruthy ( ) ;
834
+ expect ( nextBaseLayerInfo . layers . length ) . toBe ( 1 ) ;
835
+ expect ( nextBaseLayerInfo . layers ) . toEqual ( baseLayerInfoCopy . layers ) ;
836
+ expect ( map . getStyle ( ) . layers . some ( ( item ) => [ 'TIANDITU_IMG_3857' , 'ms_TIANDITU_IMG_3857_label' ] . includes ( item . id ) ) ) . toBeFalsy ( ) ;
837
+ const nextAppreciableLayers = sourceListModel . getLayers ( ) ;
838
+ expect ( nextAppreciableLayers . some ( item => item . title === baseLayerInfoCopy . layers [ 0 ] . metadata . title ) ) . toBeTruthy ( ) ;
796
839
done ( ) ;
797
840
} ) ;
798
841
} ) ;
0 commit comments