@@ -98,7 +98,6 @@ describe('openlayers_VectorTileSuperMapRest', () => {
9898 originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
9999 jasmine . DEFAULT_TIMEOUT_INTERVAL = 5000 ;
100100
101- spyGet = spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => mockCallback ( url , 'GET' ) ) ;
102101 spyPost = spyOn ( FetchRequest , 'post' ) . and . callFake ( ( url ) => mockCallback ( url , 'POST' ) ) ;
103102 spyCommit = spyOn ( FetchRequest , 'commit' ) . and . callFake ( ( method , url ) => mockCallback ( url , method ) ) ;
104103 } ) ;
@@ -116,6 +115,7 @@ describe('openlayers_VectorTileSuperMapRest', () => {
116115 } ) ;
117116
118117 it ( 'initialize' , ( done ) => {
118+ spyGet = spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => mockCallback ( url , 'GET' ) ) ;
119119 new MapService ( url ) . getMapInfo ( ( serviceResult ) => {
120120 map = new Map ( {
121121 target : 'map' ,
@@ -144,6 +144,7 @@ describe('openlayers_VectorTileSuperMapRest', () => {
144144 } ) ;
145145 } ) ;
146146 it ( 'custom_tileLoadFunction' , ( done ) => {
147+ spyGet = spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => mockCallback ( url , 'GET' ) ) ;
147148 var spy = jasmine . createSpy ( 'test' ) ;
148149 var tileLoadFunction = ( tile ) => {
149150 tile . setLoader ( ( ) => {
@@ -174,7 +175,75 @@ describe('openlayers_VectorTileSuperMapRest', () => {
174175 } ) ;
175176 } ) ;
176177
178+ it ( 'handle relative url' , ( done ) => {
179+ spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => {
180+ if ( url . indexOf ( 'fake' ) > - 1 ) {
181+ return Promise . resolve ( new Response ( JSON . stringify ( {
182+ tiles : [ 'tile/{z}/{y}/{x}.pbf' ]
183+ } ) ) ) ;
184+ }
185+ return Promise . resolve ( ) ;
186+ } ) ;
187+ new MapService ( url ) . getMapInfo ( ( serviceResult ) => {
188+ map = new Map ( {
189+ target : 'map' ,
190+ view : new View ( {
191+ center : [ 12957388 , 4853991 ] ,
192+ zoom : 11
193+ } )
194+ } ) ;
195+ vectorTileOptions = VectorTileSuperMapRest . optionsFromMapJSON ( url , serviceResult . result ) ;
196+ vectorTileOptions . tileLoadFunction = ( tile ) => {
197+ tile . setLoader ( ( ) => {
198+ tile . setFeatures ( [ ] ) ;
199+ } ) ;
200+ } ;
201+ vectorTileOptions . format = new MVT ( ) ;
202+ vectorTileOptions . baseUrl = 'http://fake/iportal/services' ;
203+ vectorTileOptions . style = {
204+ "version" : 8 ,
205+ "sprite" : "../sprites/sprite" ,
206+ "glyphs" : "../fonts/{fontstack}/{range}.pbf" ,
207+ "sources" : {
208+ "esri" : {
209+ "type" : "vector" ,
210+ "url" : "../../"
211+ }
212+ } ,
213+ "layers" : [ {
214+ "id" : "Contour_11_main/0" ,
215+ "type" : "line" ,
216+ "source" : "esri" ,
217+ "source-layer" : "Contour" ,
218+ "filter" : [ "all" , [ "==" , "Index3" , 1 ] , [ "==" , "Index5" , 1 ] ] ,
219+ "minzoom" : 11 ,
220+ "maxzoom" : 12 ,
221+ "paint" : {
222+ "line-color" : "#61674a" ,
223+ "line-opacity" : 0.5 ,
224+ "line-width" : {
225+ "base" : 1.2 ,
226+ "stops" : [ [ 11 , 0.7 ] , [ 16 , 1.1 ] ]
227+ }
228+ }
229+ } ]
230+ }
231+ vectorTileSource = new VectorTileSuperMapRest ( vectorTileOptions ) ;
232+ vectorTileSource . once ( 'tileloadend' , ( ) => {
233+ expect ( vectorTileOptions ) . not . toBeNull ( ) ;
234+ expect ( vectorTileOptions . crossOrigin ) . toBe ( 'anonymous' ) ;
235+ expect ( vectorTileSource ) . not . toBeNull ( ) ;
236+ done ( ) ;
237+ } ) ;
238+ vectorLayer = new VectorTileLayer ( {
239+ source : vectorTileSource
240+ } ) ;
241+ map . addLayer ( vectorLayer ) ;
242+ } ) ;
243+ } ) ;
244+
177245 it ( 'mvt_decrypt ' , ( done ) => {
246+ spyGet = spyOn ( FetchRequest , 'get' ) . and . callFake ( ( url ) => mockCallback ( url , 'GET' ) ) ;
178247 const spy = jasmine . createSpy ( 'test' ) ;
179248 const serviceKey = 'l3nQtAUM4li87qMfO68exInHVFQ5gS3a6pb8ySIbib8=' ;
180249 const spyEncrypt = spyOn ( EncryptRequest . prototype , 'request' ) . and . callFake ( ( ) => ( { json : ( ) => Promise . resolve ( serviceKey ) } ) ) ;
0 commit comments