Skip to content

Commit 9a76dab

Browse files
committed
补充mapbox、common下的UT;修改xit测试。review by chenmy
1 parent 1024b61 commit 9a76dab

File tree

15 files changed

+2027
-83
lines changed

15 files changed

+2027
-83
lines changed

test/classic/overlay/MapVLayerSpec.js

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@ describe('classic_MapVLayer', function () {
2727
}
2828
})]
2929
});
30-
baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("China", url, {transparent: true, cacheEnabled: true}, {maxResolution: "auto"});
30+
baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("China", url, {
31+
units:"m",
32+
transparent: true,
33+
cacheEnabled: true
34+
}, {maxResolution: "auto"});
3135
baseLayer.events.on({"layerInitialized": addLayer});
36+
3237
function addLayer() {
3338
map.addLayers([baseLayer]);
3439
map.setCenter(new SuperMap.LonLat(104, 34.7), 2);
@@ -107,7 +112,7 @@ describe('classic_MapVLayer', function () {
107112
expect(mapvLayer.renderer.canvasLayer.minScale).toEqual(590591790);
108113
});
109114

110-
it('adddata test',function () {
115+
it('adddata test', function () {
111116
var data = [{
112117
geometry: {
113118
type: 'Point',
@@ -119,7 +124,7 @@ describe('classic_MapVLayer', function () {
119124
var tempoption = {
120125
shadowBlur: 30
121126
}
122-
mapvLayer.addData(dataset,tempoption);
127+
mapvLayer.addData(dataset, tempoption);
123128

124129
expect(mapvLayer.dataSet).not.toBeNull();
125130
expect(mapvLayer.dataSet._data[1000].count).toEqual(111);
@@ -128,26 +133,27 @@ describe('classic_MapVLayer', function () {
128133
expect(mapvLayer.options.shadowBlur).toEqual(30);
129134
});
130135

131-
it('getData test',function () {
136+
it('getData test', function () {
132137
var dataset = mapvLayer.getData()
133138
expect(dataset._data.length).toEqual(1000);
134139
});
135140

141+
//删除数据 待开发修改
136142
xit('removeData test',function (done) {
137-
var filter = function(data){
138-
if( mapvLayer.dataSet._data.indexOf(data) === 2){
139-
return true
140-
}
141-
return false;
142-
}
143-
mapvLayer.removeData(filter);
144-
setTimeout(function () {
145-
expect(mapvLayer.dataSet._data.length).toEqual(999);
146-
done();
147-
},6000);
148-
});
149-
150-
it('setData test',function () {
143+
var filter = function(data){
144+
if( mapvLayer.dataSet._data.indexOf(data) === 2){
145+
return true
146+
}
147+
return false;
148+
}
149+
mapvLayer.removeData(filter);
150+
setTimeout(function () {
151+
expect(mapvLayer.dataSet._data.length).toEqual(999);
152+
done();
153+
},5000);
154+
});
155+
156+
it('setData test', function () {
151157
var data = [{
152158
geometry: {
153159
type: 'Point',
@@ -159,7 +165,7 @@ describe('classic_MapVLayer', function () {
159165
var tempoption = {
160166
shadowBlur: 40
161167
}
162-
mapvLayer.setData(dataset,tempoption);
168+
mapvLayer.setData(dataset, tempoption);
163169

164170
expect(mapvLayer.dataSet._data.length).toEqual(1);
165171
expect(mapvLayer.dataSet._data[0].count).toEqual(111);
@@ -168,7 +174,7 @@ describe('classic_MapVLayer', function () {
168174
expect(mapvLayer.options.shadowBlur).toEqual(40);
169175
});
170176

171-
it('clearData test',function () {
177+
it('clearData test', function () {
172178
mapvLayer.clearData();
173179
expect(mapvLayer.dataSet._data.length).toEqual(0);
174180
});
@@ -184,25 +190,28 @@ describe('classic_MapVLayer', function () {
184190
expect(mapvLayer.maxHeight).toBeNull();
185191
});
186192

187-
xit('setMap test', function () {
188-
var mapvLayerTemp = mapvLayer;
193+
it('setMap test', function () {
189194
mapvLayer.setMap(map);
190-
191-
expect(mapvLayer).not.toEqual(mapvLayerTemp);
195+
expect(mapvLayer).not.toBeNull();
196+
expect(mapvLayer.dataSet._data.length).toEqual(1000);
192197
});
193198

194-
xit('moveTo test', function () {
195-
var bounds = new SuperMap.Bounds(132, 33, 13, 34);
196-
var mapvLayerTemp = mapvLayer;
197-
mapvLayer.moveTo(bounds, true, false);
198-
199-
expect(mapvLayer.div.style.left).not.toBeNull();
199+
it('moveTo test', function () {
200+
var bounds = new SuperMap.Bounds(-180, -90, 180, 90);
201+
mapvLayer.moveTo(bounds, false, true);
202+
expect(mapvLayer).not.toBeNull();
203+
expect(mapvLayer.maxExtent.CLASS_NAME).toEqual("SuperMap.Bounds");
204+
expect(mapvLayer.maxExtent.bottom).toEqual(-90);
205+
expect(mapvLayer.maxExtent.left).toEqual(-180);
206+
expect(mapvLayer.maxExtent.right).toEqual(180);
207+
expect(mapvLayer.maxExtent.top).toEqual(90);
200208
});
201209

210+
//开发bug,待确认
202211
xit('transferToMapLatLng test', function () {
203-
var latlng = new SuperMap.LonLat(132, 34);
204-
var MapLatLng = mapvLayer.transferToMapLatLng(latlng);
212+
var latlng = new SuperMap.LonLat(104, 34.7);
213+
mapvLayer.transferToMapLatLng(latlng);
205214

206-
expect(MapLatLng).not.toBeNull();
215+
expect(mapvLayer).not.toBeNull();
207216
});
208217
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
require('../../../../src/common/commontypes/geometry/GeoText');
2+
3+
describe('common_GeoText', function () {
4+
5+
it('GeoText_test', function () {
6+
var x = 100, y = 35, text = "中华人民共和国";
7+
var geoText = new SuperMap.Geometry.GeoText(x, y, text);
8+
geoText.bsInfo = {
9+
h: 100,
10+
w: 150
11+
};
12+
var geoTextFeature = new SuperMap.Feature.Vector(geoText);
13+
expect(geoText).not.toBeNull();
14+
expect(geoTextFeature).not.toBeNull();
15+
expect(geoTextFeature.CLASS_NAME).toEqual("SuperMap.Feature.Vector");
16+
expect(geoTextFeature.id).not.toBeNull();
17+
expect(geoTextFeature.geometry.CLASS_NAME).toEqual("SuperMap.Geometry.GeoText");
18+
expect(geoTextFeature.geometry.id).not.toBeNull();
19+
expect(geoTextFeature.geometry.text).toEqual(text);
20+
expect(geoTextFeature.geometry.x).toEqual(x);
21+
expect(geoTextFeature.geometry.y).toEqual(y);
22+
expect(geoTextFeature.geometry.bsInfo.w).toEqual(150);
23+
expect(geoTextFeature.geometry.bsInfo.h).toEqual(100);
24+
geoText.destroy();
25+
expect(geoTextFeature.geometry.text).toBeNull();
26+
expect(geoTextFeature.geometry.x).toBeNull();
27+
expect(geoTextFeature.geometry.y).toBeNull();
28+
});
29+
30+
it('clone_test', function () {
31+
var x = 100, y = 35, text = "中华人民共和国";
32+
var geoText = new SuperMap.Geometry.GeoText(x, y, text);
33+
var obj = geoText.clone();
34+
expect(geoText).not.toBeNull();
35+
expect(geoText.id).not.toBeNull();
36+
expect(obj).not.toBeNull();
37+
expect(obj.id).not.toBeNull();
38+
expect(obj.id).not.toEqual(geoText.id);
39+
expect(obj.x).toEqual(geoText.x);
40+
expect(obj.x).toEqual(x);
41+
expect(obj.y).toEqual(geoText.y);
42+
expect(obj.y).toEqual(y);
43+
expect(obj.text).toEqual(geoText.text);
44+
expect(obj.text).toEqual(text);
45+
geoText.destroy();
46+
});
47+
48+
it('calculateBounds_test', function () {
49+
var x = 100, y = 35, text = "中华人民共和国";
50+
var geoText = new SuperMap.Geometry.GeoText(x, y, text);
51+
geoText.calculateBounds();
52+
expect(geoText).not.toBeNull();
53+
expect(geoText.bounds).not.toBeNull();
54+
expect(geoText.bounds.bottom).toEqual(geoText.bounds.top);
55+
expect(geoText.bounds.bottom).toEqual(y);
56+
expect(geoText.bounds.left).toEqual(geoText.bounds.right);
57+
expect(geoText.bounds.left).toEqual(x);
58+
geoText.destroy();
59+
});
60+
});

test/common/commontypes/geometry/LinearRingSpec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ describe('common_LinearRing Test', function () {
3333

3434

3535
//从几何组件中删除一个点。
36-
xit('removeComponent_test',function () {
37-
var removePoint = new SuperMap.Geometry.Point(5365.09521434033, -3324.5789112568386);
38-
var removedSuccess = linearRing.removeComponent(removePoint);
36+
it('removeComponent_test', function () {
37+
var removedSuccess = linearRing.removeComponent(points[2]);
3938
expect(removedSuccess).toBeTruthy();
4039
expect(linearRing.components.length).toEqual(6);
4140
});
@@ -46,7 +45,7 @@ describe('common_LinearRing Test', function () {
4645
var pointList2 = linearRing.getVertices(false);
4746
expect(pointList1.length).toEqual(0);
4847
expect(pointList2).not.toBeNull();
49-
expect(pointList2.length).toEqual(6);
48+
expect(pointList2.length).toEqual(5);
5049
});
5150

5251
});

test/leaflet/overlay/MapVLayerSpec.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('leaflet_MapVLayer', function () {
9494
done();
9595
});
9696

97-
it('adddata test',function () {
97+
it('adddata test', function () {
9898
var data = [{
9999
geometry: {
100100
type: 'Point',
@@ -106,7 +106,7 @@ describe('leaflet_MapVLayer', function () {
106106
var tempoption = {
107107
shadowBlur: 30
108108
}
109-
mapvLayer.addData(dataset,tempoption);
109+
mapvLayer.addData(dataset, tempoption);
110110

111111
expect(mapvLayer.dataSet).not.toBeNull();
112112
expect(mapvLayer.dataSet._data[1000].count).toEqual(111);
@@ -115,27 +115,27 @@ describe('leaflet_MapVLayer', function () {
115115
expect(mapvLayer.mapVOptions.shadowBlur).toEqual(30);
116116
});
117117

118-
it('getData test',function () {
118+
it('getData test', function () {
119119
var dataset = mapvLayer.getData()
120120
expect(dataset._data.length).toEqual(1000);
121121
});
122-
123-
xit('removeData test',function (done) {
124-
var filter = function(data){
125-
//if( mapvLayer.dataSet._data.indexOf(data) === 2){
126-
if(data.count = 7.439562169122387){
122+
//删除数据
123+
it('removeData test', function (done) {
124+
var filter = function (data) {
125+
if (mapvLayer.dataSet._data.indexOf(data) === 2) {
127126
return true
128127
}
129128
return false;
130129
}
130+
131131
mapvLayer.removeData(filter);
132132
setTimeout(function () {
133133
expect(mapvLayer.dataSet._data.length).toEqual(999);
134134
done();
135-
},6000);
135+
}, 6000);
136136
});
137137

138-
it('update test',function () {
138+
it('update test', function () {
139139
var data = [{
140140
geometry: {
141141
type: 'Point',
@@ -157,12 +157,12 @@ describe('leaflet_MapVLayer', function () {
157157
expect(mapvLayer.mapVOptions.shadowBlur).toEqual(40);
158158
});
159159

160-
it('clearData test',function () {
160+
it('clearData test', function () {
161161
mapvLayer.clearData();
162162
expect(mapvLayer.dataSet._data.length).toEqual(0);
163163
});
164164

165-
it('draw redraw test',function () {
165+
it('draw redraw test', function () {
166166
mapvLayer.draw();
167167
expect(mapvLayer.canvas.width).toEqual(500);
168168
expect(mapvLayer.canvas.style.width).toBe('500px');
@@ -171,24 +171,24 @@ describe('leaflet_MapVLayer', function () {
171171
expect(mapvLayer.canvas.style.width).toBe('500px');
172172
});
173173

174-
it('setZIndex test',function () {
174+
it('setZIndex test', function () {
175175
mapvLayer.setZIndex(2);
176176
expect(mapvLayer.canvas.style.zIndex).toEqual('2');
177177
});
178178

179-
it('getCanvas test',function () {
179+
it('getCanvas test', function () {
180180
var canvas = mapvLayer.getCanvas();
181181
expect(canvas).not.toBeNull();
182182
expect(mapvLayer.canvas.width).toEqual(500);
183183
expect(mapvLayer.canvas.height).toEqual(500);
184184
});
185185

186-
it('getContainer test',function () {
186+
it('getContainer test', function () {
187187
var container = mapvLayer.getContainer();
188188
expect(container).not.toBeNull();
189189
});
190190

191-
it('getTopLeft test',function () {
191+
it('getTopLeft test', function () {
192192
var topLeft = mapvLayer.getTopLeft();
193193
expect(topLeft).not.toBeNull();
194194
expect(topLeft.lng).toEqual(87.01171875);

0 commit comments

Comments
 (0)