@@ -2,6 +2,7 @@ import { SecurityManager } from '../../../src/common/security/SecurityManager';
22import { ServerInfo } from '../../../src/common/security/ServerInfo' ;
33import { TokenServiceParameter } from '../../../src/common/security/TokenServiceParameter' ;
44import { ServerType } from '../../../src/common/REST' ;
5+ import { FetchRequest } from '../../../src/common/util/FetchRequest' ;
56
67describe ( 'SecurityManager' , ( ) => {
78 var originalTimeout ;
@@ -80,13 +81,20 @@ describe('SecurityManager', () => {
8081 } ) ;
8182
8283 it ( 'loginOnline' , ( ) => {
84+ spyOn ( window , 'open' ) . and . callFake ( ( ) => { } ) ;
8385 var callbackLocation = 'Online' ;
8486 var newTab = false ;
8587 SecurityManager . loginOnline ( callbackLocation , newTab ) ;
88+ expect ( window . open ) . toHaveBeenCalled ( ) ;
8689 } ) ;
8790
8891 it ( 'loginiPortal' , ( ) => {
89- var url = 'http://localhost:8092' ;
92+ spyOn ( FetchRequest , 'post' ) . and . callFake ( ( testUrl , params , options ) => {
93+ expect ( testUrl ) . toBe ( "http://fakeiportal/web/login" ) ;
94+ expect ( params ) . not . toBeNull ( ) ;
95+ return Promise . resolve ( new Response ( `{"succeed":true}` ) ) ;
96+ } ) ;
97+ var url = 'http://fakeiportal' ;
9098 SecurityManager . loginiPortal ( url , 'admin' , 'admin' ) ;
9199 } ) ;
92100
0 commit comments