Skip to content

Commit

Permalink
[fix]webmap UT
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiao-supermap committed Aug 7, 2024
1 parent 551f51b commit 885f754
Show file tree
Hide file tree
Showing 11 changed files with 1,205 additions and 2,199 deletions.
12 changes: 0 additions & 12 deletions src/leaflet/web-map/__tests__/WebMap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ describe('WebMap.vue', () => {
});

it('initial_serverUrl', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/config/portal.json': iportal_serviceProxy,
'https://fakeiportal.supermap.io/iportal/web/maps/123/map.json': uniqueLayer_point,
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=123': layerData
};
mockFetch(fetchResource);
wrapper = mount(SmWebMap, {
localVue,
propsData: {
Expand All @@ -69,12 +63,6 @@ describe('WebMap.vue', () => {
});

it('webmap resize', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/config/portal.json': iportal_serviceProxy,
'https://fakeiportal.supermap.io/iportal/web/maps/123/map.json': uniqueLayer_point,
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=123': layerData
};
mockFetch(fetchResource);
wrapper = mount(SmWebMap, {
localVue,
propsData: {
Expand Down
52 changes: 31 additions & 21 deletions src/leaflet/web-map/__tests__/WebMapViewModel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ describe('WebMapViewModel.spec', () => {

it('uniqueLayer', () => {
const fetchResource = {
'https://www.supermapol.com/web/datas/658963918/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://www.supermapol.com/web/datas/658963918/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
const datavizWebMap_Unique = {
Expand Down Expand Up @@ -210,7 +211,8 @@ describe('WebMapViewModel.spec', () => {

it('rangeLayer', () => {
const fetchResource = {
'https://www.supermapol.com/web/datas/1236941499/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://www.supermapol.com/web/datas/1236941499/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
var datavizWebMap_Range = {
Expand Down Expand Up @@ -263,7 +265,8 @@ describe('WebMapViewModel.spec', () => {

it('heatLayer', () => {
const fetchResource = {
'https://www.supermapol.com/web/datas/675746998/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://www.supermapol.com/web/datas/675746998/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
var datavizWebMap_Heat = {
Expand Down Expand Up @@ -314,7 +317,8 @@ describe('WebMapViewModel.spec', () => {

it('add vectorLayer_point', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/1920557079/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData,
'https://fakeiportal.supermap.io/iportal/web/datas/1920557079/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData,
'https://fakeiportal.supermap.io/iportal/web/datas/13136933/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData_geojson['POINT_GEOJSON']
};
Expand All @@ -330,7 +334,8 @@ describe('WebMapViewModel.spec', () => {

it('add vectorLayer_point with SYMBOL_POINT', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/1920557079/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://fakeiportal.supermap.io/iportal/web/datas/1920557079/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
const id = {
Expand Down Expand Up @@ -362,7 +367,8 @@ describe('WebMapViewModel.spec', () => {

it('add vectorLayer_line road', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/1920557079/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://fakeiportal.supermap.io/iportal/web/datas/1920557079/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
const style = vectorLayer_line.layers[0].style;
Expand Down Expand Up @@ -390,7 +396,8 @@ describe('WebMapViewModel.spec', () => {

it('add DATAFLOW_POINT_TRACKLayer', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
const id = {
Expand Down Expand Up @@ -438,7 +445,8 @@ describe('WebMapViewModel.spec', () => {

it('add DATAFLOW_POINT_TRACKLayer with style is IMAGE_POINT', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
const id = {
Expand Down Expand Up @@ -493,12 +501,10 @@ describe('WebMapViewModel.spec', () => {

it('add DATAFLOW_POINT_TRACKLayer with style is SVG_POINT', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
window.jsonsql.query = () => {
return [{}];
};
const id = {
...ranksymbolLayer,
layers: [
Expand Down Expand Up @@ -540,7 +546,8 @@ describe('WebMapViewModel.spec', () => {
it('initial_wmtsLayer', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/config/portal.json': iportal_serviceProxy,
'http://support.supermap.com.cn:8090/iserver/services/map-china400/wmts100?REQUEST=GetCapabilities&SERVICE=WMTS&VERSION=1.0.0': wmtsCapabilitiesText
'http://support.supermap.com.cn:8090/iserver/services/map-china400/wmts100?REQUEST=GetCapabilities&SERVICE=WMTS&VERSION=1.0.0':
wmtsCapabilitiesText
};
mockFetch(fetchResource);
const callback = jest.fn();
Expand Down Expand Up @@ -597,7 +604,8 @@ describe('WebMapViewModel.spec', () => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/config/portal.json': iportal_serviceProxy,
'https://fakeiportal.supermap.io/iportal/web/maps/4845656956/map.json': ranksymbolLayer,
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
const callback = jest.fn();
Expand All @@ -612,7 +620,8 @@ describe('WebMapViewModel.spec', () => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/config/portal.json': iportal_serviceProxy,
'https://fakeiportal.supermap.io/iportal/web/maps/4845656956/map.json': markerLayer,
'https://fakeiportal.supermap.io/iportal/web/datas/123456/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData_geojson['MARKER_GEOJSON']
'https://fakeiportal.supermap.io/iportal/web/datas/123456/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData_geojson['MARKER_GEOJSON']
};
mockFetch(fetchResource);
const callback = jest.fn();
Expand All @@ -625,7 +634,8 @@ describe('WebMapViewModel.spec', () => {

it('initial_migrationLayer', async done => {
const fetchResource = {
'https://www.supermapol.com/web/datas/675746998/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://www.supermapol.com/web/datas/675746998/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
const migrationLayer = {
Expand Down Expand Up @@ -758,7 +768,8 @@ describe('WebMapViewModel.spec', () => {

it('clean', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined':
layerData
};
mockFetch(fetchResource);
const id = {
Expand Down Expand Up @@ -793,10 +804,6 @@ describe('WebMapViewModel.spec', () => {
});

it('updateDataFlowFeature', async done => {
const fetchResource = {
'https://fakeiportal.supermap.io/iportal/web/datas/676516522/content.json?pageSize=9999999&currentPage=1&parentResType=MAP&parentResId=undefined': layerData
};
mockFetch(fetchResource);
const id = {
...ranksymbolLayer,
layers: [
Expand Down Expand Up @@ -834,6 +841,7 @@ describe('WebMapViewModel.spec', () => {
const mapOption = undefined;
const callback = jest.fn();
const viewModel = new WebMapViewModel(id, { ...commonOption, map }, mapOption);
viewModel.webMapInfo = id;
viewModel.on({ addlayerssucceeded: callback });
const layerInfo = {
layerType: 'DATAFLOW_POINT_TRACK',
Expand Down Expand Up @@ -941,6 +949,8 @@ describe('WebMapViewModel.spec', () => {
}
};
await flushPromises();
viewModel._initOverlayLayer(layerInfo, [feature]);
await flushPromises();
viewModel._updateDataFlowFeature(layerInfo, { data: feature });
expect(callback.mock.called).toBeTruthy;
done();
Expand Down
Loading

0 comments on commit 885f754

Please sign in to comment.