@@ -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