Skip to content

Commit 3487cb9

Browse files
xiongjiaojiaoluoxiao-supermap
authored andcommitted
【UT】openlayers ranksymbol fix UT; review by songym
1 parent 0b74f21 commit 3487cb9

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/openlayers/overlay/RankSymbolSpec.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {ThemeFeature} from '../../../src/openlayers/overlay/theme/ThemeFeature';
44
import Map from 'ol/Map';
55
import View from 'ol/View';
66
import Point from 'ol/geom/Point';
7+
import { unByKey } from 'ol/Observable';
8+
import ImageLayer from 'ol/layer/Image';
79

810
describe('openlayers_RankSymbol', () => {
911
var testDiv, map, originalTimeout;
@@ -83,6 +85,11 @@ describe('openlayers_RankSymbol', () => {
8385
circleHoverStyle: {fillOpacity: 1}
8486
}
8587
});
88+
var layer = new ImageLayer({
89+
source: themeSource
90+
});
91+
map.addLayer(layer);
92+
expect(themeSource.features.length).toEqual(0);
8693
var features = [];
8794
for (var i = 0, len = chinaConsumptionLevel.length; i < len; i++) {
8895
// 省居民消费水平(单位:元)信息
@@ -94,13 +101,17 @@ describe('openlayers_RankSymbol', () => {
94101
var fea = new ThemeFeature(geo, attrs);
95102
features.push(fea);
96103
}
97-
themeSource.addFeatures(features);
98-
setTimeout(() => {
104+
var key = layer.on('postrender', function () {
105+
if (themeSource.charts.length > 0) {
106+
unByKey(key);
99107
themeSource.setSymbolType("Point");
100108
expect(themeSource.symbolType).toEqual("Point");
101109
themeSource.destroy();
110+
map.removeLayer(layer);
102111
done();
103-
}, 0);
112+
}
113+
});
114+
themeSource.addFeatures(features);
104115
});
105116

106117
it('createThematicFeature', (done) => {
@@ -137,4 +148,4 @@ describe('openlayers_RankSymbol', () => {
137148
}, 0);
138149
});
139150

140-
});
151+
});

0 commit comments

Comments
 (0)