Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
xilanhuaweidapao committed Aug 24, 2023
1 parent b57eea6 commit 13ab848
Show file tree
Hide file tree
Showing 9 changed files with 546 additions and 607 deletions.
45 changes: 13 additions & 32 deletions src/common/components/chart/ChartModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,8 @@ export class ChartModel {
fromIndex: 0,
toIndex: 100000
});
getFeatureBySQLService = new GetFeaturesBySQLService(datasetsInfo.dataUrl, {
eventListeners: {
processCompleted: success,
processFailed: function () {}
}
});
getFeatureBySQLService.processAsync(getFeatureBySQLParams);
getFeatureBySQLService = new GetFeaturesBySQLService(datasetsInfo.dataUrl);
getFeatureBySQLService.processAsync(getFeatureBySQLParams, success);
}

/**
Expand All @@ -108,13 +103,8 @@ export class ChartModel {
queryParams: [queryParam],
expectCount: 100000
});
queryBySQLService = new QueryBySQLService(datasetsInfo.dataUrl, {
eventListeners: {
processCompleted: success,
processFailed: function () {}
}
});
queryBySQLService.processAsync(queryBySQLParams);
queryBySQLService = new QueryBySQLService(datasetsInfo.dataUrl);
queryBySQLService.processAsync(queryBySQLParams, success);
}

/**
Expand Down Expand Up @@ -398,18 +388,14 @@ export class ChartModel {
toIndex: 100000,
returnContent: true
});
let options = {
eventListeners: {
processCompleted: (getFeaturesEventArgs) => {
processCompleted && processCompleted(getFeaturesEventArgs);
},
processFailed: (e) => {
processFaild && processFaild(e);
}
}
};
getFeatureBySQLService = new GetFeaturesBySQLService(url, options);
getFeatureBySQLService.processAsync(getFeatureBySQLParams);
getFeatureBySQLService = new GetFeaturesBySQLService(url);
getFeatureBySQLService.processAsync(getFeatureBySQLParams, function(getFeaturesEventArgs) {
if (getFeaturesEventArgs.type = 'processCompleted') {
processCompleted && processCompleted(getFeaturesEventArgs);
} else {
processFaild && processFaild(getFeaturesEventArgs);
}
});
}

/**
Expand Down Expand Up @@ -466,15 +452,10 @@ export class ChartModel {
_queryBySQL(url, params, callback, resultFormat) {
var me = this;
var queryBySQLService = new QueryBySQLService(url, {
eventListeners: {
scope: me,
processCompleted: callback,
processFailed: callback
},
format: me._processFormat(resultFormat)
});

queryBySQLService.processAsync(params);
queryBySQLService.processAsync(params, callback);
}
/**
* @function ChartModel.prototype._processFormat
Expand Down
5 changes: 1 addition & 4 deletions test/classic/services/AddressMatchServiceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ describe('classic_AddressMatchService', () => {
var codeFailed = (serviceFailedEventArgs) => {
codingFailedEventArgs = serviceFailedEventArgs;
};
var options = {
eventListeners: {"processCompleted": codeCompleted, "processFailed": codeFailed}
};
var GeoCodingParams = new GeoCodingParameter({
address: '公司',
fromIndex: 0,
Expand All @@ -72,7 +69,7 @@ describe('classic_AddressMatchService', () => {
prjCoordSys: '{epsgcode:4326}',
maxReturn: -1
});
var addressCodeService = new AddressMatchService(addressMatchURL, options);
var addressCodeService = new AddressMatchService(addressMatchURL);

spyOn(FetchRequest, 'get').and.callFake((testUrl, params, options) => {
expect(testUrl).toBe(addressMatchURL + "/geocoding");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,7 @@ describe('leaflet_clientcomputation_ClientComputationView', () => {
}

};
var options = {
eventListeners: {
'processFailed': QueryBySQLFailed,
'processCompleted': QueryBySQLCompleted
}
};
var queryBySQLService = new QueryBySQLService(queryUrl, options);
var queryBySQLService = new QueryBySQLService(queryUrl);
var params = new QueryBySQLParameters({

expectCount: 2,
Expand All @@ -98,7 +92,7 @@ describe('leaflet_clientcomputation_ClientComputationView', () => {
name: "中国历史5级以上地震_1900至2016@自然气候数据",
}))
})
queryBySQLService.processAsync(params);
queryBySQLService.processAsync(params, QueryBySQLCompleted);

});

Expand Down
10 changes: 2 additions & 8 deletions test/leaflet/components/search/SearchViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,13 @@ describe('leaflet_search_SearchView', () => {
done();
}
};
var options = {
eventListeners: {
'processFailed': QueryBySQLFailed,
'processCompleted': QueryBySQLCompleted
}
};
var polygon = L.polygon([[90, 180], [90, -180], [-90, -180], [-90, 180], [90, 180]]);
var params = new QueryBySQLParameters({
queryParams: { name: "[email protected]" },
bounds: polygon.getBounds()
});
queryBySQLService = new QueryBySQLService(queryUrl, options);
queryBySQLService.processAsync(params);
queryBySQLService = new QueryBySQLService(queryUrl);
queryBySQLService.processAsync(params, QueryBySQLCompleted);
// }, 4000);
});

Expand Down
115 changes: 56 additions & 59 deletions test/mapboxgl/overlay/RangeTheme3DLayerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,67 +66,64 @@ describe('mapboxgl_RangeTheme3DLayer', () => {
datasetNames: ["Jingjin:BaseMap_R"]
});
var queryFeatures = new GetFeaturesBySQLService(dataUrl, {
eventListeners: {
processCompleted: (serviceResult) => {
if (serviceResult.error) {
alert("error:" + JSON.stringify(serviceResult.error));
return;
}
var result = serviceResult.result;
if (result.features) {
//创建专题图图层
themeLayer = new RangeTheme3DLayer("range3DThemeLayer", {
heightField: themeField,
parseNumber: true,
enableHighlight: true,

heightStops: [
[0.01, 1000], [0.1, 5000], [0.2, 6000]
],
colorStops: [
[0, "#FDE2CA"], [0.02, "#FACE9C"], [0.04, "#F09C42"], [0.06, "#D0770B"], [0.1, "#945305"], [0.2, "#593000"]
],
// 显示图例
showLegend: true,
legendTitle: "人口密度"
});
themeLayer.setHighlightStyleOptions({color: "#058e94"});
themeLayer.setData(result.features).addTo(map);
map.easeTo({
pitch: 60,
bearing: 0
})
}
expect(themeLayer).not.toBeNull();
expect(themeLayer.colorStops.length).toEqual(6);
expect(themeLayer.data.type).toBe("FeatureCollection");
expect(themeLayer.data.features.length).toBeGreaterThan(0);
for (var i = 0; i < themeLayer.data.features.length; i++) {
expect(themeLayer.data.features[i].type).toBe("Feature");
expect(themeLayer.data.features[i].id).not.toBeNull();
expect(themeLayer.data.features[i].properties).not.toBeNull();
expect(themeLayer.data.features[i].geometry).not.toBeNull();
}
expect(themeLayer.enableHighlight).toBeTruthy();
expect(themeLayer.heightField).toBe("POP_DENSITY99");
expect(themeLayer.heightStops.length).toEqual(3);
expect(themeLayer.id).toBe("range3DThemeLayer");
expect(themeLayer._highlightLayerId).toBe("range3DThemeLayer-highlightLayer");
expect(themeLayer.highlight.color).toBe("#058e94");
expect(themeLayer.legendTitle).toBe("人口密度");
var layerStyleOptions = themeLayer.getLayerStyleOptions();
expect(layerStyleOptions).not.toBeNull();
expect(layerStyleOptions).not.toBeUndefined();
var highlightStyleOptions = themeLayer.getHighlightStyleOptions();
expect(highlightStyleOptions).not.toBeNull();
expect(highlightStyleOptions).not.toBeUndefined();
themeLayer.remove();
done();
}
},
format: DataFormat.GEOJSON
});
queryFeatures.processAsync(getFeatureBySQLParams);
queryFeatures.processAsync(getFeatureBySQLParams, (serviceResult) => {
if (serviceResult.error) {
alert("error:" + JSON.stringify(serviceResult.error));
return;
}
var result = serviceResult.result;
if (result.features) {
//创建专题图图层
themeLayer = new RangeTheme3DLayer("range3DThemeLayer", {
heightField: themeField,
parseNumber: true,
enableHighlight: true,

heightStops: [
[0.01, 1000], [0.1, 5000], [0.2, 6000]
],
colorStops: [
[0, "#FDE2CA"], [0.02, "#FACE9C"], [0.04, "#F09C42"], [0.06, "#D0770B"], [0.1, "#945305"], [0.2, "#593000"]
],
// 显示图例
showLegend: true,
legendTitle: "人口密度"
});
themeLayer.setHighlightStyleOptions({color: "#058e94"});
themeLayer.setData(result.features).addTo(map);
map.easeTo({
pitch: 60,
bearing: 0
})
}
expect(themeLayer).not.toBeNull();
expect(themeLayer.colorStops.length).toEqual(6);
expect(themeLayer.data.type).toBe("FeatureCollection");
expect(themeLayer.data.features.length).toBeGreaterThan(0);
for (var i = 0; i < themeLayer.data.features.length; i++) {
expect(themeLayer.data.features[i].type).toBe("Feature");
expect(themeLayer.data.features[i].id).not.toBeNull();
expect(themeLayer.data.features[i].properties).not.toBeNull();
expect(themeLayer.data.features[i].geometry).not.toBeNull();
}
expect(themeLayer.enableHighlight).toBeTruthy();
expect(themeLayer.heightField).toBe("POP_DENSITY99");
expect(themeLayer.heightStops.length).toEqual(3);
expect(themeLayer.id).toBe("range3DThemeLayer");
expect(themeLayer._highlightLayerId).toBe("range3DThemeLayer-highlightLayer");
expect(themeLayer.highlight.color).toBe("#058e94");
expect(themeLayer.legendTitle).toBe("人口密度");
var layerStyleOptions = themeLayer.getLayerStyleOptions();
expect(layerStyleOptions).not.toBeNull();
expect(layerStyleOptions).not.toBeUndefined();
var highlightStyleOptions = themeLayer.getHighlightStyleOptions();
expect(highlightStyleOptions).not.toBeNull();
expect(highlightStyleOptions).not.toBeUndefined();
themeLayer.remove();
done();
});
// setTimeout(() => {

// }, 5000)
Expand Down
Loading

0 comments on commit 13ab848

Please sign in to comment.