1- import { addressMatchService } from '../../../src/leaflet/services/AddressMatchService' ;
2- import { GeoCodingParameter } from '../../../src/common/iServer/GeoCodingParameter' ;
3- import { GeoDecodingParameter } from '../../../src/common/iServer/GeoDecodingParameter' ;
1+ import { addressMatchService } from '../../../src/leaflet/services/AddressMatchService' ;
2+ import { GeoCodingParameter } from '../../../src/common/iServer/GeoCodingParameter' ;
3+ import { GeoDecodingParameter } from '../../../src/common/iServer/GeoDecodingParameter' ;
44import { FetchRequest } from '../../../src/common/util/FetchRequest' ;
55
66
@@ -33,33 +33,37 @@ describe('leaflet_AddressMatchService', () => {
3333 var geoCodingService = addressMatchService ( addressMatchURL , options ) ;
3434
3535 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( testUrl , params , options ) => {
36- expect ( testUrl ) . toBe ( addressMatchURL + "/geocoding" ) ;
37- expect ( params ) . not . toBeNull ( ) ;
38- expect ( options ) . not . toBeNull ( ) ;
39- return Promise . resolve ( new Response ( codeSuccessEscapedJson ) ) ;
40- } ) ;
41- geoCodingService . code ( geoCodingParams , ( serviceResult ) => {
42- expect ( geoCodingService ) . not . toBeNull ( ) ;
43- expect ( geoCodingService . options . serverType ) . toBe ( "iServer" ) ;
44- try {
45- expect ( serviceResult . type ) . toBe ( "processCompleted" ) ;
46- var result = serviceResult . result ;
47- expect ( result ) . not . toBeNull ( ) ;
48- expect ( result . length ) . toEqual ( 10 ) ;
49- for ( var i = 0 ; i < result . length ; i ++ ) {
50- expect ( result [ i ] . filters . length ) . toEqual ( 2 ) ;
51- expect ( result [ i ] . filters [ 0 ] ) . toBe ( "北京市" ) ;
52- expect ( result [ i ] . filters [ 1 ] ) . toBe ( "海淀区" ) ;
53- }
54- expect ( result [ 0 ] . score ) . not . toBeNull ( ) ;
55- geoCodingService . destroy ( ) ;
56- done ( ) ;
57- } catch ( exception ) {
58- console . log ( "'successEvent:code'案例失败:" + exception . name + ":" + exception . message ) ;
59- geoCodingService . destroy ( ) ;
60- expect ( false ) . toBeTruthy ( ) ;
61- done ( ) ;
62- }
36+ expect ( testUrl ) . toBe ( addressMatchURL + "/geocoding" ) ;
37+ expect ( params ) . not . toBeNull ( ) ;
38+ expect ( params . address ) . toBe ( '公司' ) ;
39+ expect ( params . prjCoordSys ) . toBe ( '{epsgcode:4326}' ) ;
40+ expect ( options ) . not . toBeNull ( ) ;
41+ return Promise . resolve ( new Response ( codeSuccessEscapedJson ) ) ;
42+ } ) ;
43+
44+ geoCodingService . code ( geoCodingParams , ( result ) => {
45+ serviceResult = result ;
46+ try {
47+ expect ( geoCodingService ) . not . toBeNull ( ) ;
48+ expect ( geoCodingService . options . serverType ) . toBe ( "iServer" ) ;
49+ expect ( serviceResult . type ) . toBe ( "processCompleted" ) ;
50+ var result = serviceResult . result ;
51+ expect ( result ) . not . toBeNull ( ) ;
52+ expect ( result . length ) . toEqual ( 10 ) ;
53+ for ( var i = 0 ; i < result . length ; i ++ ) {
54+ expect ( result [ i ] . filters . length ) . toEqual ( 2 ) ;
55+ expect ( result [ i ] . filters [ 0 ] ) . toBe ( "北京市" ) ;
56+ expect ( result [ i ] . filters [ 1 ] ) . toBe ( "海淀区" ) ;
57+ }
58+ expect ( result [ 0 ] . score ) . not . toBeNull ( ) ;
59+ geoCodingService . destroy ( ) ;
60+ done ( ) ;
61+ } catch ( exception ) {
62+ console . log ( "'successEvent:code'案例失败:" + exception . name + ":" + exception . message ) ;
63+ geoCodingService . destroy ( ) ;
64+ expect ( false ) . toBeTruthy ( ) ;
65+ done ( ) ;
66+ }
6367 } ) ;
6468 } ) ;
6569
@@ -79,12 +83,15 @@ describe('leaflet_AddressMatchService', () => {
7983 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( testUrl , params , options ) => {
8084 expect ( testUrl ) . toBe ( addressMatchURL + "/geodecoding" ) ;
8185 expect ( params ) . not . toBeNull ( ) ;
86+ expect ( params . maxReturn ) . toEqual ( - 1 ) ;
87+ expect ( params . prjCoordSys ) . toBe ( '{epsgcode:4326}' ) ;
8288 expect ( options ) . not . toBeNull ( ) ;
8389 return Promise . resolve ( new Response ( decodeSuccessEscapedJson ) ) ;
8490 } ) ;
8591
86- GeoDecodingService . decode ( GeoDecodingParams , ( serviceResult ) => {
87- try {
92+ GeoDecodingService . decode ( GeoDecodingParams , ( result ) => {
93+ serviceResult = result ;
94+ try {
8895 expect ( GeoDecodingService ) . not . toBeNull ( ) ;
8996 expect ( GeoDecodingService . options . serverType ) . toBe ( "iServer" ) ;
9097 expect ( serviceResult . type ) . toBe ( "processCompleted" ) ;
@@ -121,11 +128,14 @@ describe('leaflet_AddressMatchService', () => {
121128
122129 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( testUrl , params , options ) => {
123130 expect ( testUrl ) . toBe ( addressMatchURL + "/geocoding" ) ;
131+ expect ( params . address ) . toBeNull ( ) ;
132+ expect ( params . prjCoordSys ) . toBe ( '{epsgcode:4326}' ) ;
124133 expect ( options ) . not . toBeNull ( ) ;
125134 return Promise . resolve ( new Response ( codeFailEscapedJson ) ) ;
126- } ) ;
135+ } ) ;
127136
128- geoCodingService . code ( geoCodingParams , ( serviceResult ) => {
137+ geoCodingService . code ( geoCodingParams , ( result ) => {
138+ serviceResult = result ;
129139 try {
130140 expect ( geoCodingService ) . not . toBeNull ( ) ;
131141 expect ( geoCodingService . options . serverType ) . toBe ( "iServer" ) ;
@@ -159,11 +169,14 @@ describe('leaflet_AddressMatchService', () => {
159169
160170 spyOn ( FetchRequest , 'get' ) . and . callFake ( ( testUrl , params , options ) => {
161171 expect ( testUrl ) . toBe ( addressMatchURL + "/geodecoding" ) ;
172+ expect ( params . geoDecodingRadius ) . toEqual ( 500 ) ;
173+ expect ( params . prjCoordSys ) . toBe ( '{epsgcode:4326}' ) ;
162174 expect ( options ) . not . toBeNull ( ) ;
163175 return Promise . resolve ( new Response ( decodeFailEscapedJson ) ) ;
164176 } ) ;
165177
166- geoDecodingService . decode ( GeoDecodingParams , ( serviceResult ) => {
178+ geoDecodingService . decode ( GeoDecodingParams , ( result ) => {
179+ serviceResult = result ;
167180 try {
168181 expect ( geoDecodingService ) . not . toBeNull ( ) ;
169182 expect ( geoDecodingService . options . serverType ) . toBe ( "iServer" ) ;
0 commit comments