Skip to content

Commit 8dbe6df

Browse files
committed
优化测试
1 parent 542ff66 commit 8dbe6df

File tree

1 file changed

+34
-23
lines changed

1 file changed

+34
-23
lines changed

test/openlayers/overlay/GraphSpec.js

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ describe('openlayers_graph', function () {
3232
beforeEach(function () {
3333
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
3434
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
35+
setTimeout(function() {
36+
value = 0;
37+
done();
38+
}, 5000);
3539
});
3640
afterEach(function () {
3741
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
@@ -41,7 +45,7 @@ describe('openlayers_graph', function () {
4145
map.remove();
4246
});
4347

44-
it('construtor and destroy', function () {
48+
it('construtor and destroy', function (done) {
4549
var barThemeLayer = new ol.source.Graph("BarThemeLayer", "Bar", {
4650
map: map,
4751
themeFields: ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"],
@@ -88,28 +92,31 @@ describe('openlayers_graph', function () {
8892
expect(barThemeLayer.isOverLay).toBeTruthy();
8993
expect(barThemeLayer.themeFields.length).toEqual(5);
9094
barThemeLayer.destroy();
95+
done();
9196
});
9297

93-
xit('setChartsType', function () {
94-
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
95-
map: map,
96-
chartsSetting: {
97-
width: 240,
98-
height: 100,
99-
codomain: [0, 40000]
100-
}
101-
});
102-
var layer = new ol.layer.Image({
103-
source: graphThemeSource
104-
});
105-
map.addLayer(layer);
106-
expect(graphThemeSource.chartsType).toBe("Bar");
107-
graphThemeSource.setChartsType("Line");
108-
expect(graphThemeSource.chartsType).toBe("Line");
109-
graphThemeSource.clear();
98+
it('setChartsType', function (done) {
99+
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
100+
map: map,
101+
chartsSetting: {
102+
width: 240,
103+
height: 100,
104+
codomain: [0, 40000]
105+
}
106+
});
107+
var layer = new ol.layer.Image({
108+
source: graphThemeSource
109+
});
110+
map.addLayer(layer);
111+
expect(graphThemeSource.chartsType).toBe("Bar");
112+
graphThemeSource.setChartsType("Line");
113+
expect(graphThemeSource.chartsType).toBe("Line");
114+
graphThemeSource.clear();
115+
done();
116+
110117
});
111118

112-
xit('addFeatures and removeFeatures', function () {
119+
it('addFeatures and removeFeatures', function (done) {
113120
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
114121
map: map
115122
});
@@ -186,9 +193,10 @@ describe('openlayers_graph', function () {
186193
graphThemeSource.removeAllFeatures();
187194
expect(graphThemeSource.features.length).toEqual(0);
188195
graphThemeSource.clear();
196+
done();
189197
});
190198

191-
it('isQuadrilateralOverLap', function () {
199+
it('isQuadrilateralOverLap', function (done) {
192200
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
193201
map: map,
194202
themeFields: ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"],
@@ -204,10 +212,11 @@ describe('openlayers_graph', function () {
204212
var isPointInPoly = graphThemeSource.isQuadrilateralOverLap(quadrilateral, quadrilateral2);
205213
expect(isPointInPoly).toBeTruthy();
206214
graphThemeSource.clear();
215+
done();
207216
});
208217

209218
// 此方法为iclient8的私有方法,不支持openlayers对象,此处测试传入iclient对象的情况
210-
it('isPointInPoly', function () {
219+
it('isPointInPoly', function (done) {
211220
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
212221
map: map,
213222
themeFields: ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"],
@@ -222,9 +231,10 @@ describe('openlayers_graph', function () {
222231
var isPointInPoly = graphThemeSource.isPointInPoly(point, polygon);
223232
expect(isPointInPoly).toBeTruthy();
224233
graphThemeSource.clear();
234+
done();
225235
});
226236

227-
xit('drawCharts', function (done) {
237+
it('drawCharts', function (done) {
228238
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
229239
map: map,
230240
themeFields: ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"],
@@ -264,7 +274,7 @@ describe('openlayers_graph', function () {
264274
}, 3000);
265275
});
266276

267-
it('clearCache', function () {
277+
it('clearCache', function (done) {
268278
var graphThemeSource = new ol.source.Graph("BarThemeLayer", "Bar", {
269279
map: map,
270280
themeFields: ["CON2009", "CON2010", "CON2011", "CON2012", "CON2013"],
@@ -284,5 +294,6 @@ describe('openlayers_graph', function () {
284294
expect(graphThemeSource.charts.length).toEqual(0);
285295
expect(graphThemeSource.cache).toEqual(Object({}));
286296
graphThemeSource.clear();
297+
done();
287298
});
288299
});

0 commit comments

Comments
 (0)