@@ -8,7 +8,7 @@ var url = GlobeParameter.ChinaURL + '/zxyTileImage.png?z={z}&x={x}&y={y}';
88
99describe ( 'mapboxgl L7Layer' , ( ) => {
1010 var originalTimeout ;
11- var testDiv , map , getL7Scene , setLayoutProperty ;
11+ var testDiv , map , getL7Scene , setLayoutProperty , removeLayer ;
1212 var data = [
1313 {
1414 id : '5011000000404' ,
@@ -22,17 +22,16 @@ describe('mapboxgl L7Layer', () => {
2222 beforeAll ( ( done ) => {
2323 getL7Scene = mapboxgl . Map . prototype . getL7Scene ;
2424 setLayoutProperty = mapboxgl . Map . prototype . setLayoutProperty ;
25+ removeLayer = mapboxgl . Map . prototype . removeLayer ;
2526 mbglmap . prototype . getL7Scene = getL7Scene ;
2627 mbglmap . prototype . setLayoutProperty = setLayoutProperty ;
28+
2729 spyOn ( mapboxgl , 'Map' ) . and . callFake ( mbglmap ) ;
2830
2931 spyOn ( L7 , 'PointLayer' ) . and . callFake ( mockL7 . PointLayer ) ;
3032 spyOn ( L7 , 'GeometryLayer' ) . and . callFake ( mockL7 . GeometryLayer ) ;
3133 spyOn ( L7 , 'Scene' ) . and . callFake ( mockL7 . Scene ) ;
3234 spyOn ( L7 , 'Mapbox' ) . and . callFake ( mockL7 . Mapbox ) ;
33- // Scene = mockL7.Scene;
34- // Mapbox = mockL7.Mapbox;
35- // mapboxgl.Map.prototype.getCRS = () => ({ fromWGS84: (val) => val, getExtent: () => [] });
3635 testDiv = window . document . createElement ( 'div' ) ;
3736 testDiv . setAttribute ( 'id' , 'map' ) ;
3837 testDiv . style . styleFloat = 'left' ;
@@ -65,6 +64,8 @@ describe('mapboxgl L7Layer', () => {
6564 center : [ 112 , 37.94 ] ,
6665 zoom : 13
6766 } ) ;
67+ map . removeLayer = removeLayer ;
68+ map . style . removeLayer = ( ) => { } ;
6869 map . on ( 'load' , function ( ) {
6970 done ( ) ;
7071 } ) ;
@@ -86,6 +87,7 @@ describe('mapboxgl L7Layer', () => {
8687 it ( 'getL7Scene' , ( done ) => {
8788 map . getL7Scene ( ) . then ( ( scene ) => {
8889 expect ( scene ) . not . toBeNull ( ) ;
90+ map . $l7scene = null ;
8991 done ( ) ;
9092 } ) ;
9193 } ) ;
@@ -108,6 +110,7 @@ describe('mapboxgl L7Layer', () => {
108110 . color ( '#4cfd47' ) ;
109111 map . getL7Scene ( ) . then ( ( scene ) => {
110112 expect ( scene ) . not . toBeNull ( ) ;
113+ map . $l7scene = null ;
111114 done ( ) ;
112115 } ) ;
113116 } ) ;
@@ -271,7 +274,6 @@ describe('mapboxgl L7Layer', () => {
271274 expect ( map . style . setLayoutProperty ) . toHaveBeenCalled ( ) ;
272275 expect ( layer . animateStatus ) . toBeFalsy ( ) ;
273276
274-
275277 map . setLayoutProperty ( layer . id , 'visibility' , 'visible' ) ;
276278 expect ( l7Layer . show ) . toHaveBeenCalled ( ) ;
277279 expect ( map . style . setLayoutProperty ) . toHaveBeenCalled ( ) ;
0 commit comments