Skip to content

Commit 169ab3d

Browse files
【fix】UT还原
1 parent 8c128a9 commit 169ab3d

4 files changed

Lines changed: 45 additions & 7851 deletions

File tree

test/mapboxgl/mapping/WebMapV2Spec.js

Lines changed: 39 additions & 301 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,38 @@ describe('mapboxgl_WebMapV2', () => {
351351
dataFlowServiceSpyTest = null;
352352
});
353353

354+
xit('_setCRS', (done) => {
355+
spyOn(FetchRequest, 'get').and.callFake((url) => {
356+
if (url.indexOf('portal.json') > -1) {
357+
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
358+
}
359+
if (url.indexOf('map.json') > -1) {
360+
return Promise.resolve(new Response(JSON.stringify(webmap_MAPBOXSTYLE_Tile)));
361+
}
362+
if (url.indexOf('maps/China_4326/style.json') > -1) {
363+
return Promise.resolve(new Response(styleJson));
364+
}
365+
return Promise.resolve();
366+
});
367+
datavizWebmap = new WebMap(id, {
368+
server: server
369+
});
370+
371+
spyOn(mapboxgl.CRS.prototype, 'get').and.callFake((crs) => {
372+
if (crs === 'EPSG:4326') {
373+
return crs;
374+
}
375+
return null;
376+
});
377+
datavizWebmap.on('mapcreatesucceeded', () => {
378+
spyOn(mapboxgl.CRS.prototype, 'set');
379+
datavizWebmap._handler._setCRS('EPSG:4326', 'test', { left: -180, right: 180 });
380+
expect(mapboxgl.CRS.prototype.set).not.toHaveBeenCalled();
381+
datavizWebmap._handler._setCRS('EPSG:2362', 'test', { left: -180, right: 180 });
382+
expect(mapboxgl.CRS.prototype.set).toHaveBeenCalled();
383+
done();
384+
});
385+
});
354386
it('test baseLayer layers count maploaded', (done) => {
355387
spyOn(FetchRequest, 'get').and.callFake((url) => {
356388
if (url.indexOf('portal.json') > -1) {
@@ -1404,6 +1436,8 @@ describe('mapboxgl_WebMapV2', () => {
14041436
datavizWebmap.on('mapcreatesucceeded', callback);
14051437
});
14061438

1439+
1440+
14071441
it('updateOverlayLayer unique', (done) => {
14081442
spyOn(FetchRequest, 'get').and.callFake((url) => {
14091443
if (url.indexOf('portal.json') > -1) {
@@ -1512,7 +1546,7 @@ describe('mapboxgl_WebMapV2', () => {
15121546
});
15131547
});
15141548

1515-
it('add zxytile layer 3857全球剖分', (done) => {
1549+
it('add zxytile layer', (done) => {
15161550
spyOn(FetchRequest, 'get').and.callFake((url) => {
15171551
if (url.indexOf('portal.json') > -1) {
15181552
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
@@ -2075,7 +2109,7 @@ describe('mapboxgl_WebMapV2', () => {
20752109
return Promise.resolve(new Response(JSON.stringify({})));
20762110
});
20772111
const iportalServiceProxyUrl = 'http://localhost:8195/portalproxy';
2078-
const tileCustomRequestHeaders = { Authorization: 'test token' };
2112+
const tileCustomRequestHeaders = { 'Authorization': 'test token' };
20792113
datavizWebmap = new WebMap(vectorLayer_line, {
20802114
...commonOption,
20812115
iportalServiceProxyUrlPrefix: iportalServiceProxyUrl,
@@ -2703,7 +2737,7 @@ describe('mapboxgl_WebMapV2', () => {
27032737
});
27042738
});
27052739

2706-
it('initial_xyzLayer 3857全球剖分', (done) => {
2740+
it('initial_xyzLayer', (done) => {
27072741
spyOn(FetchRequest, 'get').and.callFake((url) => {
27082742
if (url.indexOf('map.json') > -1) {
27092743
return Promise.resolve(new Response(JSON.stringify(xyzLayer)));
@@ -3253,7 +3287,7 @@ describe('mapboxgl_WebMapV2', () => {
32533287
it('updateOverlayLayer featureProjection', (done) => {
32543288
spyOn(FetchRequest, 'get').and.callFake((url) => {
32553289
if (url.indexOf('map.json') > -1) {
3256-
webmap_rangeLayer.layers.map((item) => {
3290+
webmap_rangeLayer.layers.map(item => {
32573291
item.projection = 'EPSG:3857';
32583292
});
32593293
return Promise.resolve(new Response(JSON.stringify(webmap_rangeLayer)));
@@ -3423,303 +3457,7 @@ describe('mapboxgl_WebMapV2', () => {
34233457
done();
34243458
});
34253459
});
3426-
3427-
it('webmap2.0 popupinfo', (done) => {
3428-
spyOn(FetchRequest, 'get').and.callFake((url) => {
3429-
if (url.indexOf('map.json') > -1) {
3430-
return Promise.resolve(new Response(JSON.stringify(Webmap2_popupInfo)));
3431-
} else if (url.indexOf('1168691327/content.json?') > -1) {
3432-
return Promise.resolve(new Response(JSON.stringify(chart_content)));
3433-
} else if (url.indexOf('1371715657/content.json?') > -1) {
3434-
return Promise.resolve(new Response(JSON.stringify(layerData_geojson['POINT_GEOJSON'])));
3435-
} else if (url.indexOf('portal.json') > -1) {
3436-
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
3437-
}
3438-
return Promise.resolve(new Response(JSON.stringify({})));
3439-
});
3440-
datavizWebmap = new WebMap('123', {
3441-
server: server
3442-
});
3443-
const callback = function () {
3444-
const popupInfo = datavizWebmap.getPopupInfos();
3445-
const data = [
3446-
{
3447-
elements: [
3448-
{
3449-
fieldName: 'parent',
3450-
type: 'FIELD',
3451-
fieldCaption: 'parent3121'
3452-
},
3453-
{
3454-
fieldName: 'adcode',
3455-
type: 'FIELD',
3456-
fieldCaption: 'adcode'
3457-
},
3458-
{
3459-
fieldName: 'level',
3460-
type: 'FIELD',
3461-
fieldCaption: 'level'
3462-
},
3463-
{
3464-
fieldName: 'childrenNum',
3465-
type: 'FIELD',
3466-
fieldCaption: 'childrenNum'
3467-
},
3468-
{
3469-
fieldName: 'smpid',
3470-
type: 'FIELD',
3471-
fieldCaption: 'smpid'
3472-
},
3473-
{
3474-
fieldName: 'centroid',
3475-
type: 'FIELD',
3476-
fieldCaption: 'centroid'
3477-
},
3478-
{
3479-
fieldName: 'center',
3480-
type: 'FIELD',
3481-
fieldCaption: 'center'
3482-
},
3483-
{
3484-
fieldName: 'subFeatureIndex',
3485-
type: 'FIELD',
3486-
fieldCaption: 'subFeatureIndex'
3487-
},
3488-
{
3489-
fieldName: 'name',
3490-
type: 'FIELD',
3491-
fieldCaption: 'name'
3492-
},
3493-
{
3494-
fieldName: 'acroutes',
3495-
type: 'FIELD',
3496-
fieldCaption: 'acroutes'
3497-
},
3498-
{
3499-
type: 'DIVIDER'
3500-
},
3501-
{
3502-
type: 'TEXT',
3503-
infos: [
3504-
{
3505-
insert: ['concat', ['get', 'level'], ['get', 'adcode'], '----'],
3506-
attributes: {
3507-
size: 'small',
3508-
color: '#4e35cc',
3509-
underline: true,
3510-
strike: true,
3511-
bold: true,
3512-
italic: true
3513-
}
3514-
},
3515-
{
3516-
insert: ['concat', ['get', 'childrenNum'], ['get', 'parent']],
3517-
attributes: {
3518-
size: 'small',
3519-
color: '#e01b4b'
3520-
}
3521-
},
3522-
{
3523-
insert: '\n',
3524-
attributes: {
3525-
align: 'center'
3526-
}
3527-
}
3528-
]
3529-
},
3530-
{
3531-
type: 'DIVIDER'
3532-
},
3533-
{
3534-
type: 'IMAGE',
3535-
title: ['concat', ['get', 'adcode']],
3536-
value: ['concat', ['get', 'parent']]
3537-
},
3538-
{
3539-
type: 'IMAGE',
3540-
title: 'afdfd',
3541-
value: ['concat', ['get', 'level']]
3542-
},
3543-
{
3544-
type: 'DIVIDER'
3545-
},
3546-
{
3547-
type: 'VIDEO',
3548-
title: 'fdsfs',
3549-
value: 'http://fake:8190/iportal/apps/mapstudio/edit.html'
3550-
},
3551-
{
3552-
type: 'DIVIDER'
3553-
},
3554-
{
3555-
type: 'IMAGE',
3556-
title: ['concat', ['get', 'parent'], ['get', 'adcode']],
3557-
value: ['concat', ['get', 'adcode'], ['get', 'level']]
3558-
}
3559-
],
3560-
title: '北京市(3)',
3561-
layerId: ['北京市(3)']
3562-
},
3563-
{
3564-
elements: [
3565-
{
3566-
fieldName: 'SmID',
3567-
type: 'FIELD'
3568-
},
3569-
{
3570-
fieldName: '标准名称',
3571-
type: 'FIELD'
3572-
}
3573-
],
3574-
title: '北京市轨道交通线路-打印(3)',
3575-
layerId:[ '北京市轨道交通线路-打印(3)']
3576-
}
3577-
];
3578-
expect(popupInfo).toEqual(data);
3579-
done();
3580-
};
3581-
datavizWebmap.on('mapcreatesucceeded', callback);
3582-
datavizWebmap.on('map');
3583-
});
3584-
it('webmap2.0 popupinfo no captions', (done) => {
3585-
spyOn(FetchRequest, 'get').and.callFake((url) => {
3586-
if (url.indexOf('map.json') > -1) {
3587-
return Promise.resolve(new Response(JSON.stringify(Webmap2_popupInfo_no_captions)));
3588-
} else if (url.indexOf('1168691327/content.json?') > -1) {
3589-
return Promise.resolve(new Response(JSON.stringify(chart_content)));
3590-
} else if (url.indexOf('1371715657/content.json?') > -1) {
3591-
return Promise.resolve(new Response(JSON.stringify(layerData_geojson['POINT_GEOJSON'])));
3592-
} else if (url.indexOf('portal.json') > -1) {
3593-
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
3594-
}
3595-
return Promise.resolve(new Response(JSON.stringify({})));
3596-
});
3597-
datavizWebmap = new WebMap('123', {
3598-
server: server
3599-
});
3600-
const callback = function () {
3601-
const popupInfo = datavizWebmap.getPopupInfos();
3602-
const data = [
3603-
{
3604-
elements: [
3605-
{
3606-
fieldCaption: "SmID",
3607-
fieldName: 'SmID',
3608-
type: 'FIELD'
3609-
},
3610-
{
3611-
fieldCaption: '标准名称',
3612-
fieldName: '标准名称',
3613-
type: 'FIELD'
3614-
}
3615-
],
3616-
title: '北京市轨道交通线路-打印(3)',
3617-
layerId: ['北京市轨道交通线路-打印(3)']
3618-
}
3619-
];
3620-
expect(popupInfo).toEqual(data);
3621-
done();
3622-
};
3623-
datavizWebmap.on('mapcreatesucceeded', callback);
3624-
datavizWebmap.on('map');
3625-
});
3626-
it('webmap2.0 popupinfo 没有配置弹窗', (done) => {
3627-
spyOn(FetchRequest, 'get').and.callFake((url) => {
3628-
if (url.indexOf('map.json') > -1) {
3629-
return Promise.resolve(new Response(JSON.stringify(Webmap2_popupInfo_no)));
3630-
} else if (url.indexOf('1168691327/content.json?') > -1) {
3631-
return Promise.resolve(new Response(JSON.stringify(chart_content)));
3632-
} else if (url.indexOf('1371715657/content.json?') > -1) {
3633-
return Promise.resolve(new Response(JSON.stringify(layerData_geojson['POINT_GEOJSON'])));
3634-
} else if (url.indexOf('portal.json') > -1) {
3635-
return Promise.resolve(new Response(JSON.stringify(iportal_serviceProxy)));
3636-
}
3637-
return Promise.resolve(new Response(JSON.stringify({})));
3638-
});
3639-
datavizWebmap = new WebMap('123', {
3640-
server: server
3641-
});
3642-
const callback = function () {
3643-
const popupInfo = datavizWebmap.getPopupInfos();
3644-
const data = [
3645-
{
3646-
elements: [
3647-
{
3648-
type: 'FIELD',
3649-
fieldName: 'parent',
3650-
fieldCaption: 'parent3121'
3651-
},
3652-
{
3653-
type: 'FIELD',
3654-
fieldName: 'adcode',
3655-
fieldCaption: 'adcode'
3656-
},
3657-
{
3658-
type: 'FIELD',
3659-
fieldName: 'level',
3660-
fieldCaption: 'level'
3661-
},
3662-
{
3663-
type: 'FIELD',
3664-
fieldName: 'childrenNum',
3665-
fieldCaption: 'childrenNum'
3666-
},
3667-
{
3668-
type: 'FIELD',
3669-
fieldName: 'smpid',
3670-
fieldCaption: 'smpid'
3671-
},
3672-
{
3673-
type: 'FIELD',
3674-
fieldName: 'centroid',
3675-
fieldCaption: 'centroid'
3676-
},
3677-
{
3678-
type: 'FIELD',
3679-
fieldName: 'center',
3680-
fieldCaption: 'center'
3681-
},
3682-
{
3683-
type: 'FIELD',
3684-
fieldName: 'subFeatureIndex',
3685-
fieldCaption: 'subFeatureIndex'
3686-
},
3687-
{
3688-
type: 'FIELD',
3689-
fieldName: 'name',
3690-
fieldCaption: 'name'
3691-
},
3692-
{
3693-
type: 'FIELD',
3694-
fieldName: 'acroutes',
3695-
fieldCaption: 'acroutes'
3696-
}
3697-
],
3698-
layerId:[ '北京市(3)'],
3699-
title: '北京市(3)'
3700-
},
3701-
{
3702-
elements: [
3703-
{
3704-
fieldName: 'SmID',
3705-
type: 'FIELD'
3706-
},
3707-
{
3708-
fieldName: '标准名称',
3709-
type: 'FIELD'
3710-
}
3711-
],
3712-
title: '北京市轨道交通线路-打印(3)',
3713-
layerId: ['北京市轨道交通线路-打印(3)']
3714-
}
3715-
];
3716-
expect(popupInfo).toEqual(data);
3717-
done();
3718-
};
3719-
datavizWebmap.on('mapcreatesucceeded', callback);
3720-
datavizWebmap.on('map');
3721-
});
3722-
3460+
37233461
it('baselayer is MAPBOXSTYLE when mapInfo has no extent', (done) => {
37243462
const mapInfo = {
37253463
"maxScale": "1:144447.92746805",

0 commit comments

Comments
 (0)