Skip to content

Commit b3bf360

Browse files
增加leaflet/overlay和common/iServer下的单元测试;修改站点首页样式。review by zhurch
1 parent 16e9ca8 commit b3bf360

13 files changed

+1027
-272
lines changed

karma.conf.js

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,28 @@ module.exports = function (config) {
2020
// list of files patterns to load in the browser
2121
// false 表示初始化的时候不会使用 script 标签直接将相关 js 引入到浏览器,需要自己写代码加载, 注意添加顺序
2222
files: [
23-
/***legacy文件夹下的源码添加至此***/
23+
/***legacy文件夹下的源码添加至此***/
2424
{pattern: 'src/legacy/libs/SuperMap_Basic-8.1.1-14426.js', include: false},
2525
{pattern: 'src/legacy/libs/Lang/*.js', include: false},
2626
{pattern: 'src/legacy/theme/default/*.css', include: false},
27-
/***common文件夹下的源码添加至此***/
27+
/***common文件夹下的源码添加至此***/
2828
'src/common/SuperMap.js',
2929
'src/common/REST.js',
3030
'src/common/style/CartoCSS.js',
3131
'src/common/**/*.js',
32-
/***Leaflet文件夹下的源码添加至此,暂未添加***/
32+
/***Leaflet文件夹下的源码添加至此,暂未添加***/
3333
{pattern: './node_modules/leaflet/dist/leaflet.css', include: false},
3434
'src/leaflet/**/*.js',
3535
'src/leaflet/overlay/**/*.js',
36-
/***OL3文件夹下的源码添加至此,暂未添加***/
36+
/***OL3文件夹下的源码添加至此,暂未添加***/
3737
{pattern: './node_modules/openlayers/dist/ol-debug.css', include: false},
3838
'src/openlayers/**/*.js',
3939
'src/openlayers/overlay/**/*.js',
40-
/***以下全是测试文件***/
40+
/***以下全是测试文件***/
4141
'test/tool/**.js',
42-
/**common --iServer**/
42+
/**common --iServer**/
4343
//'test/common/iServer/AreaSolarRadiationServiceSpec.js', //iclient8注释掉
44+
'test/common/iServer/AddressServiceSpec.js',
4445
'test/common/iServer/BufferAnalystServiceSpec.js',
4546
'test/common/iServer/BufferDistanceSpec.js',
4647
'test/common/iServer/BufferSettingSpec.js',
@@ -101,7 +102,7 @@ module.exports = function (config) {
101102
'test/common/iServer/UpdateTurnNodeWeightServiceSpec.js',
102103

103104
/*Leaflet、OL3、legacy文件夹测试代码,暂未添加*/
104-
/**leaflet --services**/
105+
/**leaflet --services**/
105106
'test/leaflet/services/QueryByBoundsServiceSpec.js',
106107
'test/leaflet/services/QueryByDistanceServiceSpec.js',
107108
'test/leaflet/services/QueryBySQLServiceSpec.js',
@@ -117,18 +118,20 @@ module.exports = function (config) {
117118
'test/leaflet/services/AddressServiceSpec.js',
118119
'test/leaflet/services/FieldServiceSpec.js',
119120
'test/leaflet/services/ThemeServiceSpec.js',
121+
/*overlay*/
122+
//'test/leaflet/overlay/RangeThemeLayerSpec.js',
123+
'test/leaflet/overlay/RankSymbolThemeLayerSpec.js',
124+
'test/leaflet/overlay/UniqueThemeLayerSpec.js',
120125
'test/leaflet/overlay/theme/GraphThemeLayerSpec.js',
121126

122-
/**openlayers --services**/
127+
128+
/**openlayers --services**/
123129
'test/openlayers/core/StyleUtilsSpec.js'
124130
],
125131

126132
// list of files to exclude 测试时排除的文件
127133
exclude: [
128-
//暂时先排除(因为Request引用了node_modules中的库,但在karma下识别不到路径,暂时找不到解决办法)
129-
130-
/*leaflet*/
131-
'test/leaflet/services/AddressServiceSpec.js' //启了服务再测
134+
//'test/leaflet/overlay/RangeThemeLayerSpec.js',
132135
],
133136

134137

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
require('../../../src/common/iServer/AddressService');
2+
3+
var addressMatchURL_code = GlobeParameter.addressMatchURL_code;
4+
var addressMatchURL_decode = GlobeParameter.addressMatchURL_decode;
5+
describe('testAddressService', function () {
6+
it('constructor and destroy', function () {
7+
var addressService = new SuperMap.REST.AddressService(addressMatchURL_code);
8+
expect(addressService).not.toBeNull();
9+
expect(addressService.url).toEqual(addressMatchURL_code);
10+
expect(addressService.isInTheSameDomain).toBeFalsy();
11+
addressService.destroy();
12+
expect(addressService.EVENT_TYPES).toBeNull();
13+
expect(addressService.events).toBeNull();
14+
expect(addressService.isInTheSameDomain).toBeNull();
15+
expect(addressService.options).toBeNull();
16+
expect(addressService.url).toBeNull();
17+
});
18+
});
19+
20+
describe('testAddressService异步', function () {
21+
var originalTimeout;
22+
beforeEach(function () {
23+
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
24+
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
25+
});
26+
afterEach(function () {
27+
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
28+
});
29+
it('code', function (done) {
30+
var codingFailedEventArgs = null, codingSuccessEventArgs = null;
31+
var options = {
32+
eventListeners: {"processCompleted": codeCompleted, 'processFailed': codeFailed}
33+
};
34+
35+
function codeFailed(serviceFailedEventArgs) {
36+
codingFailedEventArgs = serviceFailedEventArgs;
37+
}
38+
39+
function codeCompleted(analyseEventArgs) {
40+
codingSuccessEventArgs = analyseEventArgs;
41+
}
42+
43+
var GeoCodingParams = new SuperMap.GeoCodingParameter({
44+
address: '公司',
45+
fromIndex: 0,
46+
toIndex: 10,
47+
filters: '北京市,海淀区',
48+
prjCoordSys: '{epsgcode:4326}',
49+
maxReturn: -1
50+
});
51+
var addressCodeService = new SuperMap.REST.AddressService(addressMatchURL_code, options);
52+
addressCodeService.code(addressMatchURL_code, GeoCodingParams);
53+
setTimeout(function () {
54+
try {
55+
expect(addressCodeService).not.toBeNull();
56+
expect(codingSuccessEventArgs).not.toBeNull();
57+
expect(codingSuccessEventArgs.type).toBe('processCompleted');
58+
expect(codingSuccessEventArgs.result).not.toBeNull();
59+
expect(codingSuccessEventArgs.result.length).toEqual(10);
60+
addressCodeService.destroy();
61+
GeoCodingParams.destroy();
62+
codingFailedEventArgs = null;
63+
codingSuccessEventArgs = null;
64+
done();
65+
} catch (exception) {
66+
console.log("'code'案例失败:" + exception.name + ":" + exception.message);
67+
addressCodeService.destroy();
68+
GeoCodingParams.destroy();
69+
codingFailedEventArgs = null;
70+
codingSuccessEventArgs = null;
71+
expect(false).toBeTruthy();
72+
done();
73+
}
74+
}, 5000)
75+
});
76+
77+
it('decode', function (done) {
78+
var decodingFailedEventArgs = null, decodingSuccessEventArgs = null;
79+
var options = {
80+
eventListeners: {"processCompleted": decodeCompleted, 'processFailed': decodeFailed}
81+
};
82+
83+
function decodeFailed(serviceFailedEventArgs) {
84+
decodingFailedEventArgs = serviceFailedEventArgs;
85+
}
86+
87+
function decodeCompleted(analyseEventArgs) {
88+
decodingSuccessEventArgs = analyseEventArgs;
89+
}
90+
91+
var GeoDeCodingParams = new SuperMap.GeoDecodingParameter({
92+
x: 116.31740122415627,
93+
y: 39.92311315752059,
94+
fromIndex: 0,
95+
toIndex: 5,
96+
filters: '北京市,海淀区',
97+
prjCoordSys: '{epsgcode:4326}',
98+
maxReturn: -1,
99+
geoDecodingRadius: 500
100+
});
101+
var addressDeCodeService = new SuperMap.REST.AddressService(addressMatchURL_decode, options);
102+
addressDeCodeService.decode(addressMatchURL_decode, GeoDeCodingParams);
103+
setTimeout(function () {
104+
try {
105+
expect(addressDeCodeService).not.toBeNull();
106+
expect(decodingSuccessEventArgs).not.toBeNull();
107+
expect(decodingSuccessEventArgs.type).toBe('processCompleted');
108+
expect(decodingSuccessEventArgs.result).not.toBeNull();
109+
expect(decodingSuccessEventArgs.result.length).toEqual(5);
110+
addressDeCodeService.destroy();
111+
GeoDeCodingParams.destroy();
112+
decodingFailedEventArgs = null;
113+
decodingSuccessEventArgs = null;
114+
done();
115+
} catch (exception) {
116+
console.log("'code'案例失败:" + exception.name + ":" + exception.message);
117+
addressDeCodeService.destroy();
118+
GeoDeCodingParams.destroy();
119+
decodingFailedEventArgs = null;
120+
decodingSuccessEventArgs = null;
121+
expect(false).toBeTruthy();
122+
done();
123+
}
124+
}, 5000)
125+
});
126+
127+
});
128+
129+

0 commit comments

Comments
 (0)