Skip to content

Commit 525ae7b

Browse files
【fix】UT
1 parent a269cff commit 525ae7b

File tree

5 files changed

+206
-9
lines changed

5 files changed

+206
-9
lines changed

src/common/mapping/WebMapV2.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
185185
_getPopupInfos() {
186186
const { layers = [] } = this._mapInfo;
187187
return layers.map((layer) => {
188-
const { popupInfo, enableFields, name, layerID: id, captions: fieldCaptions } = layer;
188+
const { popupInfo, enableFields, name, layerID: layerId, captions: fieldCaptions } = layer;
189189
if (popupInfo){
190190
let elements = popupInfo.elements || [];
191191
if (fieldCaptions) {
@@ -196,15 +196,15 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo, crsMa
196196
return item;
197197
});
198198
}
199-
return { ...popupInfo, id, elements };
199+
return { ...popupInfo, layerId, elements };
200200
}
201201
if (enableFields) {
202202
const elements = enableFields.map((fieldName) => ({
203203
type: 'FIELD',
204204
fieldName,
205205
fieldCaption: fieldCaptions[fieldName] || fieldName
206206
}));
207-
return { elements, id, title: name };
207+
return { elements, layerId, title: name };
208208
}
209209
return null;
210210
}).filter(item => item !== null);

src/common/mapping/WebMapV3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ export function createWebMapV3Extending(SuperClass, { MapManager, mapRepo, crsMa
362362
return item;
363363
}) : [];
364364
}
365-
popupInfo.id = id;
365+
popupInfo.layerId = id;
366366
return popupInfo
367367
}
368368
return null

test/mapboxgl/mapping/WebMapV2Spec.js

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,7 +4146,6 @@ describe('mapboxgl_WebMapV2', () => {
41464146
server: server
41474147
});
41484148
const callback = function () {
4149-
console.log(datavizWebmap);
41504149
const popupInfo = datavizWebmap.getPopupInfos();
41514150
const data = [
41524151
{
@@ -4264,7 +4263,7 @@ describe('mapboxgl_WebMapV2', () => {
42644263
}
42654264
],
42664265
title: '北京市(3)',
4267-
id: '北京市(3)'
4266+
layerId: '北京市(3)'
42684267
},
42694268
{
42704269
elements: [
@@ -4278,7 +4277,103 @@ describe('mapboxgl_WebMapV2', () => {
42784277
}
42794278
],
42804279
title: '北京市轨道交通线路-打印(3)',
4281-
id: '北京市轨道交通线路-打印(3)'
4280+
layerId: '北京市轨道交通线路-打印(3)'
4281+
}
4282+
];
4283+
expect(popupInfo).toEqual(data);
4284+
done();
4285+
};
4286+
datavizWebmap.on('mapcreatesucceeded', callback);
4287+
datavizWebmap.on('map');
4288+
});
4289+
it('webmap2.0 popupinfo 没有配置弹窗', (done) => {
4290+
spyOn(FetchRequest, 'get').and.callFake((url) => {
4291+
if (url.indexOf('map.json') > -1) {
4292+
return Promise.resolve(new Response(JSON.stringify(Webmap2_popupInfo_no)));
4293+
} else if (url.indexOf('1168691327/content.json?') > -1) {
4294+
return Promise.resolve(new Response(JSON.stringify(chart_content)));
4295+
} else if (url.indexOf('1371715657/content.json?') > -1) {
4296+
return Promise.resolve(new Response(JSON.stringify(layerData_geojson['POINT_GEOJSON'])));
4297+
} else if (url.indexOf('portal.json') > -1) {
4298+
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
4299+
}
4300+
return Promise.resolve(new Response(JSON.stringify({})));
4301+
});
4302+
datavizWebmap = new WebMap('123', {
4303+
server: server
4304+
});
4305+
const callback = function () {
4306+
const popupInfo = datavizWebmap.getPopupInfos();
4307+
const data = [
4308+
{
4309+
elements: [
4310+
{
4311+
type: 'FIELD',
4312+
fieldName: 'parent',
4313+
fieldCaption: 'parent3121'
4314+
},
4315+
{
4316+
type: 'FIELD',
4317+
fieldName: 'adcode',
4318+
fieldCaption: 'adcode'
4319+
},
4320+
{
4321+
type: 'FIELD',
4322+
fieldName: 'level',
4323+
fieldCaption: 'level'
4324+
},
4325+
{
4326+
type: 'FIELD',
4327+
fieldName: 'childrenNum',
4328+
fieldCaption: 'childrenNum'
4329+
},
4330+
{
4331+
type: 'FIELD',
4332+
fieldName: 'smpid',
4333+
fieldCaption: 'smpid'
4334+
},
4335+
{
4336+
type: 'FIELD',
4337+
fieldName: 'centroid',
4338+
fieldCaption: 'centroid'
4339+
},
4340+
{
4341+
type: 'FIELD',
4342+
fieldName: 'center',
4343+
fieldCaption: 'center'
4344+
},
4345+
{
4346+
type: 'FIELD',
4347+
fieldName: 'subFeatureIndex',
4348+
fieldCaption: 'subFeatureIndex'
4349+
},
4350+
{
4351+
type: 'FIELD',
4352+
fieldName: 'name',
4353+
fieldCaption: 'name'
4354+
},
4355+
{
4356+
type: 'FIELD',
4357+
fieldName: 'acroutes',
4358+
fieldCaption: 'acroutes'
4359+
}
4360+
],
4361+
layerId: '北京市(3)',
4362+
title: '北京市(3)'
4363+
},
4364+
{
4365+
elements: [
4366+
{
4367+
fieldName: 'SmID',
4368+
type: 'FIELD'
4369+
},
4370+
{
4371+
fieldName: '标准名称',
4372+
type: 'FIELD'
4373+
}
4374+
],
4375+
title: '北京市轨道交通线路-打印(3)',
4376+
layerId: '北京市轨道交通线路-打印(3)'
42824377
}
42834378
];
42844379
expect(popupInfo).toEqual(data);

test/mapboxgl/mapping/WebMapV3Spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ describe('mapboxgl-webmap3.0', () => {
16921692
}
16931693
],
16941694
title: 'A点',
1695-
id: 'A点'
1695+
layerId: 'A点'
16961696
},
16971697
{
16981698
elements: [
@@ -1740,7 +1740,7 @@ describe('mapboxgl-webmap3.0', () => {
17401740
}
17411741
],
17421742
title: 'A面',
1743-
id: 'A面'
1743+
layerId: 'A面'
17441744
}
17451745
];
17461746
expect(popupInfo).toEqual(Data);

test/resources/WebMapV5.js

Lines changed: 102 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)