@@ -41,6 +41,7 @@ import {
41
41
mockCatalogUSInt ,
42
42
mockCatalogUS ,
43
43
mockCatalogEUInt ,
44
+ mockUSServiceHosts ,
44
45
} from './callingClientFixtures' ;
45
46
import Line from './line' ;
46
47
import { filterMobiusUris } from '../common/Utils' ;
@@ -67,6 +68,40 @@ describe('CallingClient Tests', () => {
67
68
} ) ;
68
69
}
69
70
71
+ describe ( 'CallingClient pick Mobius cluster using Service Host Tests' , ( ) => {
72
+ afterAll ( ( ) => {
73
+ callManager . removeAllListeners ( ) ;
74
+ webex . internal . services [ '_serviceUrls' ] [ 'mobius' ] =
75
+ 'https://mobius.aintgen-a-1.int.infra.webex.com/api/v1' ;
76
+ webex . internal . services [ '_hostCatalog' ] = mockCatalogUS ;
77
+ } ) ;
78
+
79
+ it ( 'should set mobiusServiceHost correctly when URL is valid' , async ( ) => {
80
+ webex . internal . services . _hostCatalog = mockCatalogEU ;
81
+ webex . internal . services [ '_serviceUrls' ] [ 'mobius' ] =
82
+ 'https://mobius-eu-central-1.prod.infra.webex.com/api/v1' ;
83
+ const urlSpy = jest . spyOn ( window , 'URL' ) . mockImplementation ( ( url ) => new window . URL ( url ) ) ;
84
+ const callingClient = await createClient ( webex , { logger : { level : LOGGER . INFO } } ) ;
85
+
86
+ expect ( urlSpy ) . toHaveBeenCalledWith (
87
+ 'https://mobius-eu-central-1.prod.infra.webex.com/api/v1'
88
+ ) ;
89
+
90
+ expect ( callingClient [ 'mobiusClusters' ] ) . toStrictEqual ( mockEUServiceHosts ) ;
91
+
92
+ urlSpy . mockRestore ( ) ;
93
+ } ) ;
94
+
95
+ it ( 'should use default mobius service host when Service URL is invalid' , async ( ) => {
96
+ webex . internal . services . _hostCatalog = mockCatalogUS ;
97
+ webex . internal . services . _serviceUrls . mobius = 'invalid-url' ;
98
+
99
+ const callingClient = await createClient ( webex , { logger : { level : LOGGER . INFO } } ) ;
100
+
101
+ expect ( callingClient [ 'mobiusClusters' ] ) . toStrictEqual ( mockUSServiceHosts ) ;
102
+ } ) ;
103
+ } ) ;
104
+
70
105
describe ( 'ServiceData tests' , ( ) => {
71
106
let callingClient : ICallingClient | undefined ;
72
107
0 commit comments