@@ -45,7 +45,7 @@ describe('mapboxgl_GraticuleLayer', () => {
4545 jasmine . DEFAULT_TIMEOUT_INTERVAL = 50000 ;
4646 if ( ! map . getLayer ( 'graticuleLayer_1' ) ) {
4747 graticuleLayer = new GraticuleLayer ( { layerID : 'graticuleLayer_1' } ) ;
48- graticuleLayer . onAdd ( map ) ;
48+ map . addLayer ( graticuleLayer ) ;
4949 }
5050 } ) ;
5151
@@ -73,16 +73,6 @@ describe('mapboxgl_GraticuleLayer', () => {
7373 } , 0 ) ;
7474 } ) ;
7575
76- it ( '_initialize visible' , ( done ) => {
77- setTimeout ( ( ) => {
78- const graticuleLayer = new GraticuleLayer ( { layerID : 'graticuleLayer_test' , visible : false } ) ;
79- graticuleLayer . onAdd ( map ) ;
80- var visible = map . getLayoutProperty ( 'graticuleLayer_test_line' , 'visibility' ) ;
81- expect ( visible ) . toBe ( 'none' ) ;
82- done ( ) ;
83- } , 0 ) ;
84- } ) ;
85-
8676 it ( 'setVisibility' , ( ) => {
8777 graticuleLayer . setVisibility ( false ) ;
8878 var visible = map . getLayoutProperty ( 'graticuleLayer_1_line' , 'visibility' ) ;
@@ -108,12 +98,17 @@ describe('mapboxgl_GraticuleLayer', () => {
10898 } ) ;
10999
110100 it ( 'setExtent' , ( ) => {
111- graticuleLayer . setExtent ( [
112- [ 0 , 0 ] ,
113- [ 50 , 50 ]
114- ] ) ;
115- expect ( graticuleLayer . options . extent [ 0 ] ) . toEqual ( 0 ) ;
116- expect ( graticuleLayer . options . extent [ 3 ] ) . toEqual ( 50 ) ;
101+ try {
102+ graticuleLayer . setExtent ( [
103+ [ 0 , 0 ] ,
104+ [ 50 , 50 ]
105+ ] ) ;
106+ expect ( graticuleLayer . options . extent [ 0 ] ) . toEqual ( 0 ) ;
107+ expect ( graticuleLayer . options . extent [ 3 ] ) . toEqual ( 50 ) ;
108+ } catch ( e ) {
109+ expect ( false ) . toBeTruthy ( ) ;
110+ console . log ( e ) ;
111+ }
117112 } ) ;
118113
119114 it ( 'setStrokeStyle' , ( ) => {
@@ -132,34 +127,24 @@ describe('mapboxgl_GraticuleLayer', () => {
132127 } ) ;
133128
134129 it ( 'setIntervals' , ( ) => {
135- graticuleLayer . setIntervals ( 5 ) ;
136- expect ( graticuleLayer . renderer . options . interval ) . toEqual ( 5 ) ;
130+ try {
131+ graticuleLayer . setIntervals ( 5 ) ;
132+ expect ( graticuleLayer . renderer . options . interval ) . toEqual ( 5 ) ;
133+ } catch ( e ) {
134+ expect ( false ) . toBeTruthy ( ) ;
135+ console . log ( e ) ;
136+ }
137137 } ) ;
138138
139139 it ( 'getDefaultExtent must return degree' , ( ) => {
140140 map . getCRS = ( ) => {
141141 return {
142- extent : [
143- - 20037508.3427892 ,
144- - 20037508.3427892 ,
145- 20037508.3427892 ,
146- 20037508.3427892
147- ] ,
148- lngLatExtent : [
149- - 179.99999999999963 ,
150- - 85.05112877980658 ,
151- 179.99999999999963 ,
152- 85.05112877980656
153- ]
142+ extent : [ - 20037508.3427892 , - 20037508.3427892 , 20037508.3427892 , 20037508.3427892 ] ,
143+ lngLatExtent : [ - 179.99999999999963 , - 85.05112877980658 , 179.99999999999963 , 85.05112877980656 ]
154144 } ;
155145 } ;
156146 var extent = graticuleLayer . getDefaultExtent ( ) ;
157- expect ( extent ) . toEqual ( [
158- - 179.99999999999963 ,
159- - 85.05112877980658 ,
160- 179.99999999999963 ,
161- 85.05112877980656
162- ] ) ;
147+ expect ( extent ) . toEqual ( [ - 179.99999999999963 , - 85.05112877980658 , 179.99999999999963 , 85.05112877980656 ] ) ;
163148 } ) ;
164149
165150 it ( '_calcInterval' , ( ) => {
@@ -189,8 +174,45 @@ describe('mapboxgl_GraticuleLayer', () => {
189174 expect ( points [ 0 ] [ 1 ] ) . toEqual ( 80 ) ;
190175 } ) ;
191176
177+ xit ( '_setLayerTop add newlayer' , ( ) => {
178+ console . log ( '_setLayerTop add newlayer' ) ;
179+ try {
180+ map . addSource ( 'queryDatas' , {
181+ type : 'geojson' ,
182+ data : {
183+ type : 'FeatureCollection' ,
184+ features : [ { type : 'Feature' , geometry : { type : 'Polygon' , coordinates : [ [ [ 0 , 0 ] [ ( 10 , 5 ) ] , [ - 10 , 5 ] ] ] } } ]
185+ }
186+ } ) ;
187+ map . addLayer ( {
188+ id : 'queryDatas' ,
189+ type : 'fill' ,
190+ source : 'queryDatas' ,
191+ paint : {
192+ 'fill-color' : '#008080' ,
193+ 'fill-opacity' : 0.4
194+ } ,
195+ filter : [ '==' , '$type' , 'Polygon' ]
196+ } ) ;
197+ expect ( true ) . toBeTruthy ( ) ;
198+ } catch ( e ) {
199+ expect ( false ) . toBeTruthy ( ) ;
200+ console . log ( e ) ;
201+ }
202+ } ) ;
203+
192204 it ( 'onRemove' , ( ) => {
193205 graticuleLayer . onRemove ( ) ;
194206 expect ( graticuleLayer . renderer . canvas ) . toBeNull ( ) ;
195207 } ) ;
208+
209+ it ( '_initialize visible' , ( done ) => {
210+ setTimeout ( ( ) => {
211+ const graticuleLayer = new GraticuleLayer ( { layerID : 'graticuleLayer_test' , visible : false } ) ;
212+ map . addLayer ( graticuleLayer ) ;
213+ var visible = map . getLayoutProperty ( 'graticuleLayer_test_line' , 'visibility' ) ;
214+ expect ( visible ) . toBe ( 'none' ) ;
215+ done ( ) ;
216+ } , 0 ) ;
217+ } ) ;
196218} ) ;
0 commit comments