Skip to content

Commit 90fe878

Browse files
committed
【fix】优化测试
1 parent f74bec5 commit 90fe878

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

test/openlayers/overlay/VectorTileSuperMapRestMapboxstyleSpec.js

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('openlayers_VectorTileSuperMapRest_mapboxStyle', () => {
4848
});
4949
beforeEach(() => {
5050
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
51-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
51+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
5252
});
5353
afterEach(() => {
5454
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
@@ -71,11 +71,21 @@ describe('openlayers_VectorTileSuperMapRest_mapboxStyle', () => {
7171
format: format
7272
})
7373
});
74-
spyOn(vectorLayer.getSource(), 'tileLoadFunction').and.callThrough();
75-
setTimeout(() => {
76-
expect(vectorLayer.getSource().tileLoadFunction.calls.count()).toEqual(4)
77-
done();
78-
}, 0);
74+
spyOn(vectorLayer.getSource(), 'tileLoadFunction').and.callFake((tile)=>{
75+
tile.setLoader(()=>{
76+
tile.setFeatures([])
77+
})
78+
});
79+
let count = 0;
80+
vectorLayer.getSource().on('tileloadend',()=>{
81+
count++;
82+
console.log(count)
83+
if(count === 4){
84+
expect(vectorLayer.getSource().tileLoadFunction.calls.count()).toEqual(4);
85+
done();
86+
}
87+
88+
})
7989
map.addLayer(vectorLayer);
8090

8191
});
@@ -92,12 +102,22 @@ describe('openlayers_VectorTileSuperMapRest_mapboxStyle', () => {
92102
format: format
93103
})
94104
});
95-
spyOn(vectorLayer.getSource(), 'tileLoadFunction').and.callThrough();
96-
setTimeout(() => {
97-
expect(vectorLayer.getSource()._tileUrl).toContain("California");
98-
expect(vectorLayer.getSource().tileLoadFunction.calls.count()).toEqual(4)
99-
done();
100-
}, 0);
105+
spyOn(vectorLayer.getSource(), 'tileLoadFunction').and.callFake((tile)=>{
106+
tile.setLoader(()=>{
107+
tile.setFeatures([])
108+
})
109+
});
110+
let count = 0;
111+
vectorLayer.getSource().on('tileloadend',()=>{
112+
count++;
113+
console.log(count)
114+
if(count === 4){
115+
expect(vectorLayer.getSource()._tileUrl).toContain("California");
116+
expect(vectorLayer.getSource().tileLoadFunction.calls.count()).toEqual(4);
117+
done();
118+
}
119+
120+
})
101121
map.addLayer(vectorLayer);
102122

103123
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy