@@ -45,7 +45,7 @@ describe('mapboxgl_GraticuleLayer', () => {
45
45
jasmine . DEFAULT_TIMEOUT_INTERVAL = 50000 ;
46
46
if ( ! map . getLayer ( 'graticuleLayer_1' ) ) {
47
47
graticuleLayer = new GraticuleLayer ( { layerID : 'graticuleLayer_1' } ) ;
48
- graticuleLayer . onAdd ( map ) ;
48
+ map . addLayer ( graticuleLayer ) ;
49
49
}
50
50
} ) ;
51
51
@@ -73,16 +73,6 @@ describe('mapboxgl_GraticuleLayer', () => {
73
73
} , 0 ) ;
74
74
} ) ;
75
75
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
-
86
76
it ( 'setVisibility' , ( ) => {
87
77
graticuleLayer . setVisibility ( false ) ;
88
78
var visible = map . getLayoutProperty ( 'graticuleLayer_1_line' , 'visibility' ) ;
@@ -108,12 +98,17 @@ describe('mapboxgl_GraticuleLayer', () => {
108
98
} ) ;
109
99
110
100
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
+ }
117
112
} ) ;
118
113
119
114
it ( 'setStrokeStyle' , ( ) => {
@@ -132,34 +127,24 @@ describe('mapboxgl_GraticuleLayer', () => {
132
127
} ) ;
133
128
134
129
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
+ }
137
137
} ) ;
138
138
139
139
it ( 'getDefaultExtent must return degree' , ( ) => {
140
140
map . getCRS = ( ) => {
141
141
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 ]
154
144
} ;
155
145
} ;
156
146
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 ] ) ;
163
148
} ) ;
164
149
165
150
it ( '_calcInterval' , ( ) => {
@@ -189,8 +174,45 @@ describe('mapboxgl_GraticuleLayer', () => {
189
174
expect ( points [ 0 ] [ 1 ] ) . toEqual ( 80 ) ;
190
175
} ) ;
191
176
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
+
192
204
it ( 'onRemove' , ( ) => {
193
205
graticuleLayer . onRemove ( ) ;
194
206
expect ( graticuleLayer . renderer . canvas ) . toBeNull ( ) ;
195
207
} ) ;
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
+ } ) ;
196
218
} ) ;
0 commit comments