Skip to content

Commit 48e3388

Browse files
修改leaflet专题图单元测试案例。
1 parent 8833ebf commit 48e3388

File tree

2 files changed

+42
-25
lines changed

2 files changed

+42
-25
lines changed

test/leaflet/overlay/UniqueThemeLayerSpec.js

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,14 @@ describe('leaflet_testUniqueThemeLayer', function () {
254254
features = IHFeas.concat(features);
255255
expect(features.length).toBeGreaterThan(0);
256256
done();
257+
} else {
258+
console.log("未能通过'getFeaturesBySQL'方法获取接下来'addFeatures'方法所需要的数据");
259+
done();
257260
}
258-
}, 4000);
261+
}, 6000);
259262
});
260263

261-
it('addFeatures', function () {
264+
it('addFeatures', function (done) {
262265
//constructor
263266
var uniqueThemeLayer = L.supermap.uniqueThemeLayer("ThemeLayer", {
264267
isHoverAble: true,
@@ -356,27 +359,41 @@ describe('leaflet_testUniqueThemeLayer', function () {
356359
expect(uniqueThemeLayer.themeField).toBe("LANDTYPE");
357360
expect(uniqueThemeLayer.features.length).toEqual(0);
358361
// addFeatures
359-
uniqueThemeLayer.addFeatures(features);
360-
expect(uniqueThemeLayer.features.length).toBeGreaterThan(0);
361-
// getCacheCount
362-
var cacheCount = uniqueThemeLayer.getCacheCount();
363-
expect(cacheCount).toBeGreaterThan(0);
364-
// setMaxCacheCount
365-
expect(uniqueThemeLayer.maxCacheCount).toBeGreaterThan(10);
366-
uniqueThemeLayer.setMaxCacheCount(10);
367-
expect(uniqueThemeLayer.maxCacheCount).toEqual(10);
368-
// getShapesByFeatureID
369-
var shape1 = uniqueThemeLayer.getShapesByFeatureID();
370-
var shape2 = uniqueThemeLayer.getShapesByFeatureID(features[0].ID);
371-
expect(shape1.length).toBeGreaterThan(0);
372-
expect(shape2.length).toEqual(0);
373-
// redraw
374-
var isRedraw = uniqueThemeLayer.redraw();
375-
expect(isRedraw).toBeTruthy();
376-
// removeFeatures
377-
uniqueThemeLayer.removeFeatures(features);
378-
uniqueThemeLayer.removeAllFeatures();
379-
expect(uniqueThemeLayer.features.length).toEqual(0);
380-
uniqueThemeLayer.clear();
362+
if (features.length != 0) {
363+
uniqueThemeLayer.addFeatures(features);
364+
setTimeout(function () {
365+
try {
366+
expect(uniqueThemeLayer.features.length).toBeGreaterThan(0);
367+
// getCacheCount
368+
var cacheCount = uniqueThemeLayer.getCacheCount();
369+
expect(cacheCount).toBeGreaterThan(0);
370+
// setMaxCacheCount
371+
expect(uniqueThemeLayer.maxCacheCount).toBeGreaterThan(10);
372+
uniqueThemeLayer.setMaxCacheCount(10);
373+
expect(uniqueThemeLayer.maxCacheCount).toEqual(10);
374+
// getShapesByFeatureID
375+
var shape1 = uniqueThemeLayer.getShapesByFeatureID();
376+
var shape2 = uniqueThemeLayer.getShapesByFeatureID(features[0].ID);
377+
expect(shape1.length).toBeGreaterThan(0);
378+
expect(shape2.length).toEqual(0);
379+
// redraw
380+
var isRedraw = uniqueThemeLayer.redraw();
381+
expect(isRedraw).toBeTruthy();
382+
// removeFeatures
383+
uniqueThemeLayer.removeFeatures(features);
384+
uniqueThemeLayer.removeAllFeatures();
385+
expect(uniqueThemeLayer.features.length).toEqual(0);
386+
uniqueThemeLayer.clear();
387+
done();
388+
} catch (exception) {
389+
console.log("'addFeatures'案例失败:" + exception.name + ":" + exception.message);
390+
themeUniqueService.destroy();
391+
expect(false).toBeTruthy();
392+
done();
393+
}
394+
}, 6000);
395+
} else {
396+
console.log("'addFeatures'案例未获取到待添加的数据");
397+
}
381398
});
382399
});

test/leaflet/services/ThemeServiceSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ describe('leaflet_testThemeService', function () {
267267
expect(false).toBeTruthy();
268268
done();
269269
}
270-
}, 3000)
270+
}, 6000)
271271
});
272272

273273
// 标签专题图

0 commit comments

Comments
 (0)