1
1
import { spatialAnalystService } from '../../../src/leaflet/services/SpatialAnalystService' ;
2
2
import { DensityKernelAnalystParameters } from '../../../src/common/iServer/DensityKernelAnalystParameters' ;
3
3
import request from 'request' ;
4
+ import { FetchRequest } from "@supermap/iclient-common" ;
4
5
5
6
var spatialAnalystURL = GlobeParameter . spatialAnalystURL_Changchun ;
6
7
var options = {
@@ -35,18 +36,22 @@ describe('leaflet_SpatialAnalystService_densityAnalysis', () => {
35
36
deleteExistResultDataset : true
36
37
} ) ;
37
38
var densityAnalystService = spatialAnalystService ( spatialAnalystURL , options ) ;
38
- densityAnalystService . densityAnalysis ( densityAnalystParameters , ( densityServiceResult ) => {
39
- serviceResult = densityServiceResult ;
39
+ spyOn ( FetchRequest , 'commit' ) . and . callFake ( ( method , testUrl , params , options ) => {
40
+ expect ( method ) . toBe ( "POST" ) ;
41
+ expect ( testUrl ) . toBe ( spatialAnalystURL + "/datasets/Railway@Changchun/densityanalyst/kernel.json?returnContent=true" ) ;
42
+ var expectParams = `{'bounds':{'left':3800,'bottom':-3800,'right':8200,'top':-2200,'centerLonLat':null},'fieldName':"SmLength",'resultGridDatasetResolution':null,'searchRadius':50,'targetDatasource':null,'resultGridName':"KernelDensity_leafletTest",'deleteExistResultDataset':true}` ;
43
+ expect ( params ) . toBe ( expectParams ) ;
44
+ expect ( options ) . not . toBeNull ( ) ;
45
+ return Promise . resolve ( new Response ( expectParams ) ) ;
46
+ } ) ;
47
+ densityAnalystService . densityAnalysis ( densityAnalystParameters , ( result ) => {
48
+ serviceResult = result ;
40
49
} ) ;
41
50
setTimeout ( ( ) => {
42
51
try {
43
- expect ( densityAnalystService ) . not . toBeNull ( ) ;
44
52
expect ( serviceResult ) . not . toBeNull ( ) ;
45
- expect ( serviceResult . type ) . toBe ( "processCompleted" ) ;
46
- var result = serviceResult . result ;
47
- expect ( result ) . not . toBeNull ( ) ;
48
- expect ( result . dataset ) . toEqual ( resultDataset + "@Changchun" ) ;
49
- expect ( result . succeed ) . toBe ( true ) ;
53
+ expect ( serviceResult . type ) . toBe ( 'processCompleted' ) ;
54
+ expect ( serviceResult . result . succeed ) . toBeTruthy ( ) ;
50
55
densityAnalystService . destroy ( ) ;
51
56
done ( ) ;
52
57
} catch ( exception ) {
@@ -58,10 +63,4 @@ describe('leaflet_SpatialAnalystService_densityAnalysis', () => {
58
63
} , 5000 ) ;
59
64
} ) ;
60
65
61
- // 删除测试过程中产生的测试数据集
62
- it ( 'delete test resources' , ( done ) => {
63
- var testResult = GlobeParameter . datachangchunURL + resultDataset ;
64
- request . delete ( testResult ) ;
65
- done ( ) ;
66
- } ) ;
67
66
} ) ;
0 commit comments