11import { IPortalUser } from '../../../src/common/iPortal/iPortalUser' ;
2+ import { FetchRequest } from '../../../src/common/util/FetchRequest' ;
23
34describe ( 'IPortalUser' , ( ) => {
5+ beforeAll ( ( ) => {
6+ spyOn ( FetchRequest , 'commit' ) . and . callFake ( ( method , testUrl , params ) => {
7+ return Promise . resolve ( new Response ( "{}" ) ) ;
8+ } ) ;
9+ } )
410 it ( 'constructor_default' , ( ) => {
511 var iportalUrl = 'https://iptl.supermap.io/iportal' ;
612 var iPortalUser = new IPortalUser ( iportalUrl ) ;
@@ -13,7 +19,7 @@ describe('IPortalUser', () => {
1319 expect ( iPortalUser . deleteResources ( { ids : [ ] , resourceType : "MAP" } ) instanceof Promise ) . toBeTruthy ( ) ;
1420 } ) ;
1521
16- it ( 'addMap' , ( ) => {
22+ it ( 'addMap' , ( done ) => {
1723 let iportalUrl = 'https://iptl.supermap.io/iportal' ;
1824 let iPortalUser = new IPortalUser ( iportalUrl ) ;
1925 // 传入错误的参数
@@ -30,11 +36,12 @@ describe('IPortalUser', () => {
3036 ]
3137 } ;
3238 iPortalUser . addMap ( addMapParams ) . then ( res => {
33- expect ( res ) . toBe ( "addMapParams is not instanceof IPortalAddMapParam !" ) ;
39+ expect ( res ) . toBe ( "addMapParams is not instanceof IPortalAddResourceParam !" ) ;
40+ done ( ) ;
3441 } )
3542 } ) ;
3643
37- it ( 'addScene' , ( ) => {
44+ it ( 'addScene' , ( done ) => {
3845 let iportalUrl = 'https://iptl.supermap.io/iportal' ;
3946 let iPortalUser = new IPortalUser ( iportalUrl ) ;
4047 // 传入错误的参数
@@ -51,11 +58,12 @@ describe('IPortalUser', () => {
5158 ]
5259 } ;
5360 iPortalUser . addScene ( addSceneParams ) . then ( res => {
54- expect ( res ) . toBe ( "addSceneParams is not instanceof IPortalAddSceneParam !" ) ;
61+ expect ( res ) . toBe ( "addSceneParams is not instanceof IPortalAddResourceParam !" ) ;
62+ done ( ) ;
5563 } )
5664 } ) ;
5765
58- it ( 'registerService' , ( ) => {
66+ it ( 'registerService' , ( done ) => {
5967 let iportalUrl = 'https://iptl.supermap.io/iportal' ;
6068 let iPortalUser = new IPortalUser ( iportalUrl ) ;
6169 // 传入错误的参数
@@ -75,7 +83,8 @@ describe('IPortalUser', () => {
7583 addedSceneNames : [ ]
7684 }
7785 iPortalUser . registerService ( registerServiceParams ) . then ( res => {
78- expect ( res ) . toBe ( "registerParams is not instanceof iPortalRegisterServiceParam !" ) ;
86+ expect ( res ) . toBe ( "registerParams is not instanceof IPortalRegisterServiceParam !" ) ;
87+ done ( ) ;
7988 } )
8089 } )
8190
@@ -102,7 +111,7 @@ describe('IPortalUser', () => {
102111 expect ( iPortalUser . addData ( addDataParam , formData ) instanceof Promise ) . toBeTruthy ( ) ;
103112 } ) ;
104113
105- it ( 'publishOrUnpublish' , ( ) => {
114+ it ( 'publishOrUnpublish' , ( done ) => {
106115 var options = {
107116 dataId :null ,
108117 serviceType :'RESTDATA' ,
@@ -113,6 +122,7 @@ describe('IPortalUser', () => {
113122 var iPortalUser = new IPortalUser ( iportalUrl ) ;
114123 iPortalUser . publishOrUnpublish ( options , forPublish ) . then ( res => {
115124 expect ( res ) . toBe ( "option.dataID and option.serviceType are Required!" ) ;
125+ done ( ) ;
116126 } )
117127 } ) ;
118128
@@ -124,7 +134,7 @@ describe('IPortalUser', () => {
124134 expect ( iPortalUser . getDataPublishedStatus ( dataId , dataServiceId ) instanceof Promise ) . toBeTruthy ( ) ;
125135 } ) ;
126136
127- it ( 'unPublishDataService' , ( ) => {
137+ it ( 'unPublishDataService' , ( done ) => {
128138 var options = {
129139 dataId :1 ,
130140 serviceType :null ,
@@ -134,10 +144,11 @@ describe('IPortalUser', () => {
134144 var iPortalUser = new IPortalUser ( iportalUrl ) ;
135145 iPortalUser . unPublishDataService ( options ) . then ( res => {
136146 expect ( res ) . toBe ( "option.dataID and option.serviceType are Required!" ) ;
147+ done ( ) ;
137148 } )
138149 } ) ;
139150
140- it ( 'publishDataService' , ( ) => {
151+ it ( 'publishDataService' , ( done ) => {
141152 var options = {
142153 dataId :1 ,
143154 serviceType :null ,
@@ -147,6 +158,7 @@ describe('IPortalUser', () => {
147158 var iPortalUser = new IPortalUser ( iportalUrl ) ;
148159 iPortalUser . publishDataService ( options ) . then ( res => {
149160 expect ( res ) . toBe ( "option.dataID and option.serviceType are Required!" ) ;
161+ done ( ) ;
150162 } )
151163 } ) ;
152164} ) ;
0 commit comments