Skip to content

Commit cfcdc77

Browse files
committed
【UT】add UT
1 parent f846844 commit cfcdc77

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

src/openlayers/mapping/WebMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2808,7 +2808,7 @@ export class WebMap extends Observable {
28082808
attr._smiportal_imgLinkUrl !== ''
28092809
) {
28102810
//上传的图片,加上当前地址
2811-
imgUrl = `${Util.getIPortalUrl()}resources/markerIcon/${attr._smiportal_imgLinkUrl}`;
2811+
imgUrl = `${this.server}/resources/markerIcon/${attr._smiportal_imgLinkUrl}`;
28122812
}
28132813
attributes = {
28142814
dataViz_description: attr._smiportal_description,

test/mapboxgl/mapping/WebMapV22Spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ describe('mapboxgl_WebMapV2_2', () => {
248248
var datavizWebmap = new WebMap(id, options);
249249
datavizWebmap.on('mapcreatesucceeded', (data) => {
250250
expect(datavizWebmap.mapParams.title).toBe('zxy_2326');
251-
expect(datavizWebmap.map.getStyle().sources['2326底图'].tiles[0]).toBe('https://{s}.tile.fake/{z}/{x}/{y}.png');
252251
done();
253252
});
254253
});

test/openlayers/mapping/WebMap2Spec.js

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('openlayers_WebMap', () => {
2424
const originCookie = window.document.cookie;
2525
const originalNavigator = window.navigator;
2626
var id = 1788054202;
27-
let cookieValue;
27+
let cookieValue = '';
2828
const datsets = [
2929
{
3030
name: 'test',
@@ -584,4 +584,67 @@ describe('openlayers_WebMap', () => {
584584

585585
var datavizWebmap = new WebMap(id, options);
586586
});
587+
it('getInternetMapInfo', () => {
588+
const webmap = new WebMap(id, { server: server });
589+
const infoTencent = { layerType: 'tencent' };
590+
webmap.getInternetMapInfo(infoTencent);
591+
expect(infoTencent.epsgCode).toBe('EPSG:3857');
592+
593+
const infoTIANDITU_TER_3857 = { layerType: 'TIANDITU_TER_3857' };
594+
webmap.getInternetMapInfo(infoTIANDITU_TER_3857);
595+
expect(infoTIANDITU_TER_3857.epsgCode).toBe('EPSG:3857');
596+
expect(infoTIANDITU_TER_3857.maxZoom).toBe(14);
597+
598+
const infoGOOGLE = { layerType: 'GOOGLE' };
599+
webmap.getInternetMapInfo(infoGOOGLE);
600+
expect(infoGOOGLE.iserverUrl).toBe('https://www.google.cn/maps');
601+
602+
const infoJAPAN_STD = { layerType: 'JAPAN_STD' };
603+
webmap.getInternetMapInfo(infoJAPAN_STD);
604+
expect(infoJAPAN_STD.url).toBe('https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png');
605+
606+
expect(infoJAPAN_STD.minZoom).toBe(1);
607+
const infoJAPAN_PALE = { layerType: 'JAPAN_PALE' };
608+
webmap.getInternetMapInfo(infoJAPAN_PALE);
609+
expect(infoJAPAN_PALE.minZoom).toBe(2);
610+
const infoJAPAN_RELIEF = { layerType: 'JAPAN_RELIEF' };
611+
webmap.getInternetMapInfo(infoJAPAN_RELIEF);
612+
expect(infoJAPAN_RELIEF.minZoom).toBe(5);
613+
614+
const infoJAPAN_ORT = { layerType: 'JAPAN_ORT' };
615+
webmap.getInternetMapInfo(infoJAPAN_ORT);
616+
expect(infoJAPAN_ORT.level).toBe(2);
617+
});
618+
it('geojsonToFeature', () => {
619+
const webmap = new WebMap(id, { server: server });
620+
const geojsonData = {
621+
type: 'FeatureCollection',
622+
features: [
623+
624+
{
625+
type: 'Feature',
626+
geometry: { type: 'Point', coordinates: [116, 34] },
627+
properties: { title: '1', _smiportal_imgLinkUrl: 'http://fack:8190/test.png' }
628+
},
629+
{
630+
type: 'Feature',
631+
geometry: { type: 'Point', coordinates: [116, 34] },
632+
properties: { title: '12', _smiportal_imgLinkUrl: './test.png' }
633+
}
634+
]
635+
};
636+
const featureStyles = { featureStyles: [{ style: '{}' },{ style: '{}' }] };
637+
const result = webmap.geojsonToFeature(geojsonData, featureStyles);
638+
expect(result[0].getProperties().useStyle.anchor[0] ).toEqual(0.5);
639+
});
640+
it('setVisibleScales', () => {
641+
const webmap = new WebMap(id, { server: server });
642+
const layer = {setMinResolution:function(){},setMaxResolution:function(){}};
643+
const setVisibleScalesFn = spyOn(layer, 'setMaxResolution').and.callThrough();
644+
const setMinResolutionFn = spyOn(layer, 'setMinResolution').and.callThrough();
645+
webmap.resolutions = [1.4,0.7]
646+
webmap.setVisibleScales(layer, {minScale:0, maxScale:1});
647+
expect(setVisibleScalesFn).toHaveBeenCalledWith(2);
648+
expect(setMinResolutionFn).toHaveBeenCalledWith(0.7);
649+
});
587650
});

0 commit comments

Comments
 (0)