Skip to content

Commit d9d6d54

Browse files
[fix]service修改options添加后UT修改 review by qiw
1 parent 7391756 commit d9d6d54

Some content is hidden

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

42 files changed

+552
-233
lines changed

src/common/iServer/MapService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class MapService extends CommonServiceBase {
125125
var codeStatus = (result.code >= 200 && result.code < 300) || result.code == 0 || result.code === 304;
126126
var isCodeValid = result.code && codeStatus;
127127
if (!result.code || isCodeValid) {
128-
me.events && me.events.triggerEvent("processCompleted", {result: result});
128+
me.events && me.events.triggerEvent("processCompleted", {result: result, options});
129129
} else {
130130
////在没有token是返回的是200,但是其实是没有权限,所以这里也应该是触发失败事件
131131
me.events.triggerEvent("processFailed", {error: result, options});

test/classic/overlay/MapVLayerSpec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ describe('classic_MapVLayer', () => {
147147
it('destroy', () => {
148148
mapvLayer.destroy();
149149
expect(mapvLayer.dataSet).toBeNull();
150-
expect(mapvLayer.options).toBeNull();
151150
expect(mapvLayer.renderer).toBeNull();
152151
expect(mapvLayer.supported).toBeNull();
153152
expect(mapvLayer.canvasContext).toBeNull();

test/classic/services/AddressMatchServiceSpec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ describe('classic_AddressMatchService', () => {
2323
expect(addressMatchService.EVENT_TYPES).toBeNull();
2424
expect(addressMatchService.events).toBeNull();
2525
expect(addressMatchService.isInTheSameDomain).toBeNull();
26-
expect(addressMatchService.options).toBeNull();
2726
expect(addressMatchService.url).toBeNull();
2827
});
2928

test/classic/services/DatasetServiceSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ describe('classic_DatasetService', () => {
124124
expect(serviceResult).not.toBeNull();
125125
expect(serviceResult.type).toBe("processCompleted");
126126
expect(serviceResult.object.events).not.toBeNull();
127-
expect(serviceResult.object.options).not.toBeNull;
127+
expect(serviceResult.options).not.toBeNull;
128128
expect(serviceResult.result.succeed).toBe(true);
129129
done();
130130
} catch (exception) {
@@ -156,7 +156,7 @@ describe('classic_DatasetService', () => {
156156
expect(serviceResult).not.toBeNull();
157157
expect(serviceResult.type).toBe("processCompleted");
158158
expect(serviceResult.object.events).not.toBeNull();
159-
expect(serviceResult.object.options).not.toBeNull;
159+
expect(serviceResult.options).not.toBeNull;
160160
expect(serviceResult.result.succeed).toBe(true);
161161
done();
162162
} catch (exception) {

test/common/iServer/AddressMatchServiceSpec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ describe('AddressMatchService', () => {
2424
expect(addressMatchService.EVENT_TYPES).toBeNull();
2525
expect(addressMatchService.events).toBeNull();
2626
expect(addressMatchService.isInTheSameDomain).toBeNull();
27-
expect(addressMatchService.options).toBeNull();
2827
expect(addressMatchService.url).toBeNull();
2928
});
3029

test/common/iServer/EditFeaturesServiceSpec.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ describe('EditFeaturesService', () => {
3131
expect(addFeatureService.isInTheSameDomain).toBeTruthy();
3232
expect(addFeatureService.isUseBatch).toBeFalsy();
3333
expect(addFeatureService.returnContent).toBeTruthy();
34-
expect(addFeatureService.options.method).toBe("POST");
35-
expect(addFeatureService.options.data).toContain("'parts':[4]");
36-
expect(addFeatureService.options.data).toContain('"REGION"');
34+
expect(addFeatureSuccessEventArgsSystem.options.method).toBe("POST");
35+
expect(addFeatureSuccessEventArgsSystem.options.data).toContain("'parts':[4]");
36+
expect(addFeatureSuccessEventArgsSystem.options.data).toContain('"REGION"');
3737
expect(serviceResult).not.toBeNull();
3838
expect(serviceResult.succeed).toBeTruthy();
3939
expect(serviceResult[0]).not.toBeNull();
@@ -100,7 +100,7 @@ describe('EditFeaturesService', () => {
100100
expect(updateFeaturesService.isInTheSameDomain).toBeTruthy();
101101
expect(updateFailedEventArgsSystem).toBeNull();
102102
expect(updateSuccessEventArgsSystem.type).toBe("processCompleted");
103-
expect(updateSuccessEventArgsSystem.object.options.method).toBe("PUT");
103+
expect(updateSuccessEventArgsSystem.options.method).toBe("PUT");
104104
expect(updateSuccessEventArgsSystem.result.succeed).toBeTruthy();
105105
updateFeaturesService.destroy();
106106
updateFeaturesParams.destroy();
@@ -162,8 +162,8 @@ describe('EditFeaturesService', () => {
162162

163163
expect(deleteSuccessEventArgsSystem.type).toBe("processCompleted");
164164
var id = "[" + id1 + "]";
165-
expect(deleteSuccessEventArgsSystem.object.options.data).toBe(id);
166-
expect(deleteSuccessEventArgsSystem.object.options.method).toBe("DELETE");
165+
expect(deleteSuccessEventArgsSystem.options.data).toBe(id);
166+
expect(deleteSuccessEventArgsSystem.options.method).toBe("DELETE");
167167
expect(deleteSuccessEventArgsSystem.result.succeed).toBeTruthy();
168168
deleteFeaturesService.destroy();
169169
deleteFeaturesParams.destroy();
@@ -212,8 +212,8 @@ describe('EditFeaturesService', () => {
212212
try {
213213
expect(deleteSuccessEventArgsSystem.type).toBe("processCompleted");
214214
var id = JSON.stringify(ids);
215-
expect(deleteSuccessEventArgsSystem.object.options.data).toBe(id);
216-
expect(deleteSuccessEventArgsSystem.object.options.method).toBe("POST");
215+
expect(deleteSuccessEventArgsSystem.options.data).toBe(id);
216+
expect(deleteSuccessEventArgsSystem.options.method).toBe("POST");
217217
expect(deleteSuccessEventArgsSystem.result.succeed).toBeTruthy();
218218
deleteFeaturesService.destroy();
219219
deleteFeaturesParams.destroy();
@@ -262,8 +262,8 @@ describe('EditFeaturesService', () => {
262262
try {
263263
expect(deleteSuccessEventArgsSystem.type).toBe("processCompleted");
264264
var id = JSON.stringify(ids);
265-
expect(deleteSuccessEventArgsSystem.object.options.data).toBe(id);
266-
expect(deleteSuccessEventArgsSystem.object.options.method).toBe("POST");
265+
expect(deleteSuccessEventArgsSystem.options.data).toBe(id);
266+
expect(deleteSuccessEventArgsSystem.options.method).toBe("POST");
267267
expect(deleteSuccessEventArgsSystem.result.succeed).toBeTruthy();
268268
deleteFeaturesService.destroy();
269269
deleteFeaturesParams.destroy();
@@ -306,7 +306,7 @@ describe('EditFeaturesService', () => {
306306

307307
expect(noParamsFailedEventArgsSystem).not.toBeNull();
308308
expect(noParamsFailedEventArgsSystem.type).toBe('processFailed');
309-
expect(noParamsFailedEventArgsSystem.object.options.method).toBe('POST');
309+
expect(noParamsFailedEventArgsSystem.options.method).toBe('POST');
310310
expect(noParamsFailedEventArgsSystem.error).not.toBeNull();
311311
expect(noParamsFailedEventArgsSystem.error.code).toEqual(400);
312312
expect(noParamsFailedEventArgsSystem.error.errorMsg).not.toBeNull();

test/common/iServer/GeoprocessingServiceSpec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ describe('GeoprocessingService', () => {
2121
expect(geoprocessing.url).toEqual(serverUrl);
2222
geoprocessing.destroy();
2323
expect(geoprocessing.EVENT_TYPES).toBeNull();
24-
expect(geoprocessing.options).toBeNull();
2524
expect(geoprocessing.url).toBeNull();
2625
});
2726

test/common/iServer/ImageCollectionServiceSpec.js

Lines changed: 79 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -345,35 +345,85 @@ describe('ImageCollectionService', () => {
345345
service.getItemByID('featureId');
346346
});
347347

348-
it('should call getItemByID parameter wrong', function (done) {
349-
var getFeatureProcessFailed = (res) => {
350-
try {
351-
expect(res.error.description).not.toBeNull();
352-
expect(res.error.code).toEqual(400);
353-
service.destroy();
354-
expect(service.EVENT_TYPES).toBeNull();
355-
expect(service.events).toBeNull();
356-
done();
357-
} catch (exception) {
358-
expect(false).toBeTruthy();
359-
console.log('ImageCollectionService' + exception.name + ':' + exception.message);
360-
service.destroy();
361-
done();
362-
}
363-
};
364-
service = new ImageCollectionService(requestUrl, {
365-
collectionId: 'wrongId',
366-
eventListeners: {
367-
processFailed: getFeatureProcessFailed
368-
}
369-
});
370-
spyOn(FetchRequest, 'get').and.callFake((url) => {
371-
expect(url).toEqual(requestUrl + '/collections/wrongId/items/wrongId');
372-
return Promise.resolve(
373-
new Response(`{"succeed":false,"error":{"code":400,"description":"not found in resources."}}`)
374-
);
375-
});
376-
service.getItemByID('wrongId');
348+
it('should call getTileInfo getStatistics getLegend', function (done) {
349+
var queryParams = {
350+
renderingRule: new ImageRenderingRule({ displayMode: 'Composite' })
351+
};
352+
service = new ImageCollectionService(requestUrl, { collectionId: 'collectionId' });
353+
spyOn(FetchRequest, 'get').and.callFake((url) => {
354+
if(url.includes('tileInfo')) {
355+
expect(url).toEqual(requestUrl + '/collections/collectionId/tileInfo');
356+
return Promise.resolve(new Response(JSON.stringify(getCollectionTileInfoJson)));
357+
}
358+
if(url.includes('statistics')) {
359+
expect(url).toEqual(requestUrl + '/collections/collectionId/statistics');
360+
return Promise.resolve(new Response(JSON.stringify(getCollectionStatisticsJson)));
361+
}
362+
if(url.includes('legend')) {
363+
expect(url).toEqual(requestUrl + '/collections/collectionId/legend');
364+
return Promise.resolve(new Response(JSON.stringify(getCollectionLegendJson)));
365+
}
366+
if(url.includes('items')) {
367+
expect(url).toEqual(requestUrl + '/collections/collectionId/items/wrongId');
368+
return Promise.resolve(
369+
new Response(`{"succeed":false,"error":{"code":400,"description":"not found in resources."}}`)
370+
);
371+
}
372+
});
373+
service.getTileInfo((res) => {
374+
try {
375+
var result = res.result;
376+
expect(result).not.toBeNull();
377+
expect(result.origin).not.toBeNull();
378+
expect(result.levels[0]).not.toBeNull();
379+
expect(result.format).toEqual('string');
380+
expect(result.crs).toEqual('string');
381+
expect(result.width).toEqual(0);
382+
expect(result.height).toEqual(0);
383+
expect(result.dpi).toEqual(0);
384+
} catch (exception) {
385+
expect(false).toBeTruthy();
386+
console.log('ImageCollectionService' + exception.name + ':' + exception.message);
387+
}
388+
});
389+
service.getStatistics((res) => {
390+
try {
391+
var result = res.result;
392+
expect(result).not.toBeNull();
393+
expect(result.extent).not.toBeNull();
394+
expect(result.storageType[0]).toEqual('Local');
395+
expect(result.collectionId).toEqual('string');
396+
expect(result.pixelType).toEqual('UNKNOWN');
397+
expect(result.bandCount).toEqual(0);
398+
} catch (exception) {
399+
expect(false).toBeTruthy();
400+
console.log('ImageCollectionService' + exception.name + ':' + exception.message);
401+
}
402+
});
403+
service.getLegend(queryParams, (res) => {
404+
try {
405+
var result = res.result;
406+
expect(result).not.toBeNull();
407+
expect(result.layerId).toEqual(0);
408+
expect(result.layerName).toEqual('DLTB');
409+
expect(result.legendType).toEqual('Unique Values');
410+
expect(result.legendCells.length).toEqual(1);
411+
} catch (exception) {
412+
expect(false).toBeTruthy();
413+
console.log('ImageCollectionService' + exception.name + ':' + exception.message);
414+
}
415+
});
416+
service.getItemByID('wrongId', (res) => {
417+
try {
418+
expect(res.error.description).not.toBeNull();
419+
expect(res.error.code).toEqual(400);
420+
} catch (exception) {
421+
expect(false).toBeTruthy();
422+
console.log('ImageCollectionService' + exception.name + ':' + exception.message);
423+
} finally {
424+
done();
425+
}
426+
});
377427
});
378428

379429
xit('should call patchFeature successfully', function (done) {

test/common/iServer/KnowledgeGraphServiceSpec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('KnowledgeGraphService', () => {
1919
expect(knowledgeGraphService.url).toEqual(knowledgegraphURL);
2020
knowledgeGraphService.destroy();
2121
expect(knowledgeGraphService.events).toBeNull();
22-
expect(knowledgeGraphService.options).toBeNull();
2322
expect(knowledgeGraphService.url).toBeNull();
2423
});
2524

test/common/iServer/MapServiceSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ describe('MapService', () => {
134134
expect(serviceFailedEventArgsSystem).not.toBeNull();
135135
expect(serviceFailedEventArgsSystem.type).toBe('processFailed');
136136
expect(serviceFailedEventArgsSystem.error).not.toBeNull();
137-
expect(serviceFailedEventArgsSystem.object.options.method).toBe('GET');
137+
expect(serviceFailedEventArgsSystem.options.method).toBe('GET');
138138
done();
139139
} catch (exception) {
140140
expect(false).toBeTruthy();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy