Skip to content

Commit b7148ae

Browse files
classic、mapboxgl、部分common测试代码升级ES6
1 parent 364f523 commit b7148ae

File tree

99 files changed

+16248
-2456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+16248
-2456
lines changed

package-lock.json

Lines changed: 13680 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/classic/overlay/MapVLayerSpec.js

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
require('../../../src/classic/overlay/MapVLayer');
1+
import {MapVLayer} from '../../../src/classic/overlay/MapVLayer';
2+
import {Bounds} from '../../../src/common/commontypes/Bounds';
3+
import {LonLat} from '../../../src/common/commontypes/LonLat';
4+
25
var mapv = require('mapv');
36
window.mapv = mapv;
47

58
var url = GlobeParameter.ChinaURL;
6-
describe('classic_MapVLayer', function () {
9+
describe('classic_MapVLayer', () => {
710
var originalTimeout;
811
var testDiv, map, baseLayer, mapvLayer;
9-
beforeAll(function () {
12+
beforeAll(() => {
1013
testDiv = window.document.createElement("div");
1114
testDiv.setAttribute("id", "map");
1215
testDiv.style.styleFloat = "left";
@@ -15,29 +18,19 @@ describe('classic_MapVLayer', function () {
1518
testDiv.style.width = "500px";
1619
testDiv.style.height = "500px";
1720
window.document.body.appendChild(testDiv);
18-
map = new SuperMap.Map("map", {
19-
controls: [
20-
new SuperMap.Control.Attribution(),
21-
new SuperMap.Control.ScaleLine(),
22-
new SuperMap.Control.Zoom(),
23-
new SuperMap.Control.Navigation({
24-
dragPanOptions: {
25-
enableKinetic: true
26-
}
27-
})]
28-
});
21+
map = new SuperMap.Map("map");
2922
baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("China", url, {
3023
units: "m",
3124
transparent: true,
3225
cacheEnabled: true
3326
}, {maxResolution: "auto"});
34-
baseLayer.events.on({"layerInitialized": addLayer});
35-
function addLayer() {
27+
var addLayer = () => {
3628
map.addLayers([baseLayer]);
37-
map.setCenter(new SuperMap.LonLat(104, 34.7), 2);
29+
map.setCenter(new LonLat(104, 34.7), 2);
3830
}
31+
baseLayer.events.on({"layerInitialized": addLayer()});
3932
});
40-
beforeEach(function () {
33+
beforeEach(() => {
4134
//创建mapVLayer
4235
var randomCount = 1000;
4336
var data = [];
@@ -70,22 +63,21 @@ describe('classic_MapVLayer', function () {
7063
gradient: {0.25: "rgb(0,0,255)", 0.55: "rgb(0,255,0)", 0.85: "yellow", 1.0: "rgb(255,0,0)"},
7164
draw: 'honeycomb'
7265
};
73-
mapvLayer = new SuperMap.Layer.MapVLayer("mapv", {dataSet: dataSet, options: options});
66+
mapvLayer = new MapVLayer("mapv", {dataSet: dataSet, options: options});
7467
map.addLayer(mapvLayer);
7568
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
7669
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
7770
});
78-
afterEach(function () {
71+
afterEach(() => {
7972
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
8073
mapvLayer.destroy();
8174
});
82-
afterAll(function () {
75+
afterAll(() => {
8376
document.body.removeChild(testDiv);
84-
//map.destroy();
8577
mapv = null;
8678
});
8779

88-
it('constructor', function () {
80+
it('constructor', () => {
8981
expect(mapvLayer).not.toBeNull();
9082
expect(mapvLayer.options.shadowBlur).toEqual(20);
9183
expect(mapvLayer.options.draw).toBe("honeycomb");
@@ -99,7 +91,7 @@ describe('classic_MapVLayer', function () {
9991
expect(mapvLayer.renderer.canvasLayer.minScale).toEqual(590591790);
10092
});
10193

102-
it('addData', function () {
94+
it('addData', () => {
10395
var data = [{
10496
geometry: {
10597
type: 'Point',
@@ -119,12 +111,12 @@ describe('classic_MapVLayer', function () {
119111
expect(mapvLayer.options.shadowBlur).toEqual(30);
120112
});
121113

122-
it('getData', function () {
114+
it('getData', () => {
123115
var dataset = mapvLayer.getData()
124116
expect(dataset._data.length).toEqual(1000);
125117
});
126118

127-
it('setData', function () {
119+
it('setData', () => {
128120
var data = [{
129121
geometry: {
130122
type: 'Point',
@@ -144,12 +136,12 @@ describe('classic_MapVLayer', function () {
144136
expect(mapvLayer.options.shadowBlur).toEqual(40);
145137
});
146138

147-
it('clearData', function () {
139+
it('clearData', () => {
148140
mapvLayer.clearData();
149141
expect(mapvLayer.dataSet._data.length).toEqual(0);
150142
});
151143

152-
it('destroy', function () {
144+
it('destroy', () => {
153145
mapvLayer.destroy();
154146
expect(mapvLayer.dataSet).toBeNull();
155147
expect(mapvLayer.options).toBeNull();
@@ -161,28 +153,28 @@ describe('classic_MapVLayer', function () {
161153
});
162154

163155
//方法引用错误
164-
xit('removeData', function (done) {
165-
var filter = function (data) {
156+
xit('removeData', (done) => {
157+
var filter = (data) => {
166158
if (mapvLayer.dataSet._data.indexOf(data) === 2) {
167159
return true
168160
}
169161
return false;
170162
}
171163
mapvLayer.removeData(filter);
172-
setTimeout(function () {
164+
setTimeout(() => {
173165
expect(mapvLayer.dataSet._data.length).toEqual(999);
174166
done();
175167
}, 5000);
176168
});
177169

178-
xit('setMap', function () {
170+
xit('setMap', () => {
179171
mapvLayer.setMap(map);
180172
expect(mapvLayer).not.toBeNull();
181173
expect(mapvLayer.dataSet._data.length).toEqual(1000);
182174
});
183175

184-
xit('moveTo', function () {
185-
var bounds = new SuperMap.Bounds(-180, -90, 180, 90);
176+
xit('moveTo', () => {
177+
var bounds = new Bounds(-180, -90, 180, 90);
186178
mapvLayer.moveTo(bounds, false, true);
187179
expect(mapvLayer).not.toBeNull();
188180
expect(mapvLayer.maxExtent.CLASS_NAME).toEqual("SuperMap.Bounds");
@@ -192,8 +184,8 @@ describe('classic_MapVLayer', function () {
192184
expect(mapvLayer.maxExtent.top).toEqual(90);
193185
});
194186

195-
xit('transferToMapLatLng', function () {
196-
var latlng = new SuperMap.LonLat(104, 34.7);
187+
xit('transferToMapLatLng', () => {
188+
var latlng = new LonLat(104, 34.7);
197189
mapvLayer.transferToMapLatLng(latlng);
198190
expect(mapvLayer).not.toBeNull();
199191
});

test/classic/services/AddressMatchServiceSpec.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
require('../../../src/classic/services/AddressMatchService');
1+
import {AddressMatchService} from '../../../src/classic/services/AddressMatchService';
2+
import {GeoCodingParameter} from '../../../src/common/iServer/GeoCodingParameter';
3+
import {GeoDecodingParameter} from '../../../src/common/iServer/GeoDecodingParameter';
24

35
var addressMatchURL = GlobeParameter.addressMatchURL;
4-
describe('classic_AddressMatchService', function () {
6+
describe('classic_AddressMatchService', () => {
57
var originaTimeout;
6-
beforeEach(function () {
8+
beforeEach(() => {
79
originaTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
810
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
911
});
10-
afterEach(function () {
12+
afterEach(() => {
1113
jasmine.DEFAULT_TIMEOUT_INTERVAL = originaTimeout;
1214
});
1315

14-
it('constructor, destroy', function () {
15-
var addressMatchService = new SuperMap.REST.AddressMatchService(addressMatchURL);
16+
it('constructor, destroy', () => {
17+
var addressMatchService = new AddressMatchService(addressMatchURL);
1618
expect(addressMatchService).not.toBeNull();
1719
expect(addressMatchService.url).toEqual(addressMatchURL);
1820
expect(addressMatchService.isInTheSameDomain).toBeFalsy();
@@ -24,31 +26,28 @@ describe('classic_AddressMatchService', function () {
2426
expect(addressMatchService.url).toBeNull();
2527
});
2628

27-
it('code', function (done) {
29+
it('code', (done) => {
2830
var codingFailedEventArgs = null, codingSuccessEventArgs = null;
2931
var options = {
3032
eventListeners: {"processCompleted": codeCompleted, "processFailed": codeFailed}
3133
};
32-
33-
function codeCompleted(analyseEventArgs) {
34+
var codeCompleted = (analyseEventArgs) => {
3435
codingSuccessEventArgs = analyseEventArgs;
35-
}
36-
37-
function codeFailed(serviceFailedEventArgs) {
36+
};
37+
var codeFailed = (serviceFailedEventArgs) => {
3838
codingFailedEventArgs = serviceFailedEventArgs;
39-
}
40-
41-
var GeoCodingParams = new SuperMap.GeoCodingParameter({
39+
};
40+
var GeoCodingParams = new GeoCodingParameter({
4241
address: '公司',
4342
fromIndex: 0,
4443
toIndex: 10,
4544
filters: '北京市,海淀区',
4645
prjCoordSys: '{epsgcode:4326}',
4746
maxReturn: -1
4847
});
49-
var addressCodeService = new SuperMap.REST.AddressMatchService(addressMatchURL, options);
48+
var addressCodeService = new AddressMatchService(addressMatchURL, options);
5049
addressCodeService.code(GeoCodingParams, codeCompleted);
51-
setTimeout(function () {
50+
setTimeout(() => {
5251
try {
5352
expect(addressCodeService).not.toBeNull();
5453
expect(codingSuccessEventArgs).not.toBeNull();
@@ -72,17 +71,16 @@ describe('classic_AddressMatchService', function () {
7271
}, 5000);
7372
});
7473

75-
it('decode', function (done) {
74+
it('decode', (done) => {
7675
var decodingFailedEventArgs = null, decodingSuccessEventArgs = null;
77-
function decodeFailed(serviceFailedEventArgs) {
76+
var decodeFailed = (serviceFailedEventArgs) => {
7877
decodingFailedEventArgs = serviceFailedEventArgs;
79-
}
80-
81-
function decodeCompleted(analyseEventArgs) {
78+
};
79+
var decodeCompleted = (analyseEventArgs) => {
8280
decodingSuccessEventArgs = analyseEventArgs;
83-
}
81+
};
8482

85-
var GeoDeCodingParams = new SuperMap.GeoDecodingParameter({
83+
var GeoDeCodingParams = new GeoDecodingParameter({
8684
x: 116.31740122415627,
8785
y: 39.92311315752059,
8886
fromIndex: 0,
@@ -92,9 +90,9 @@ describe('classic_AddressMatchService', function () {
9290
maxReturn: -1,
9391
geoDecodingRadius: 500
9492
});
95-
var addressDeCodeService = new SuperMap.REST.AddressMatchService(addressMatchURL);
93+
var addressDeCodeService = new AddressMatchService(addressMatchURL);
9694
addressDeCodeService.decode(GeoDeCodingParams, decodeCompleted);
97-
setTimeout(function () {
95+
setTimeout(() => {
9896
try {
9997
expect(addressDeCodeService).not.toBeNull();
10098
expect(decodingSuccessEventArgs).not.toBeNull();

0 commit comments

Comments
 (0)