@@ -102,10 +102,11 @@ describe('AlertingLeader', () => {
102102 const clientOptions = { alertableInteractionTypes : [ AlertableInteractionTypes . voice ] } ;
103103 const fakeClient = new FakeClient ( { apiHost : 'example.com' } ) as unknown as Client ;
104104 const alertingLeader = new AlertingLeaderExtension ( fakeClient , clientOptions as IClientOptions ) ;
105+ const alertingLeaderExposedApi = alertingLeader . expose ;
105106 const expectedPayload = { voice : { alerting : true , configured : false } } ;
106107
107108 expect . assertions ( 4 ) ;
108- alertingLeader . expose . on ( 'alertingLeaderChanged' , ( event ) => {
109+ alertingLeaderExposedApi . on ( 'alertingLeaderChanged' , ( event ) => {
109110 expect ( event ) . toMatchObject ( expectedPayload ) ;
110111 } ) ;
111112
@@ -124,7 +125,7 @@ describe('AlertingLeader', () => {
124125 alertingLeader [ 'getAlertingLeader' ] = jest . fn ( ) . mockRejectedValue ( { } ) ;
125126 await alertingLeader [ 'setupAlertingLeader' ] ( ) ;
126127
127- expect ( alertingLeader . expose . leaderStatus ) . toMatchObject ( expectedPayload ) ;
128+ expect ( alertingLeaderExposedApi . getLeaderStatus ( ) ) . toMatchObject ( expectedPayload ) ;
128129 } ) ;
129130
130131 it ( 'should not set up alerting leader if not configured' , async ( ) => {
@@ -165,6 +166,7 @@ describe('AlertingLeader', () => {
165166 fakeClient . config . userId = userId ;
166167 const alertingLeader = new AlertingLeaderExtension ( fakeClient , { } as IClientOptions ) ;
167168 alertingLeader [ 'connectionId' ] = connectionId ;
169+ const alertingLeaderExposedApi = alertingLeader . expose ;
168170 fakeClient . _notifications . _subscribeInternal = jest . fn ( ) . mockResolvedValue ( { } ) ;
169171 const hawkPayload = {
170172 eventBody : {
@@ -175,14 +177,14 @@ describe('AlertingLeader', () => {
175177 const expectedEventPayload = { voice : { alerting : true , configured : true } } ;
176178
177179 expect . assertions ( 2 ) ;
178- alertingLeader . expose . on ( 'alertingLeaderChanged' , ( event ) => {
180+ alertingLeaderExposedApi . on ( 'alertingLeaderChanged' , ( event ) => {
179181 expect ( event ) . toMatchObject ( expectedEventPayload ) ;
180182 } ) ;
181183
182184 await alertingLeader [ 'subscribeToAlertingLeader' ] ( ) ;
183185 fakeClient . emit ( `notify:v2.users.${ userId } .alertingleader` , hawkPayload ) ;
184186
185- expect ( alertingLeader . expose . leaderStatus ) . toStrictEqual ( expectedEventPayload ) ;
187+ expect ( alertingLeaderExposedApi . getLeaderStatus ( ) ) . toStrictEqual ( expectedEventPayload ) ;
186188 } ) ;
187189
188190 it ( 'should include the clientType if present' , async ( ) => {
@@ -193,6 +195,7 @@ describe('AlertingLeader', () => {
193195 fakeClient . config . userId = userId ;
194196 const alertingLeader = new AlertingLeaderExtension ( fakeClient , { } as IClientOptions ) ;
195197 alertingLeader [ 'connectionId' ] = connectionId ;
198+ const alertingLeaderExposedApi = alertingLeader . expose ;
196199 fakeClient . _notifications . _subscribeInternal = jest . fn ( ) . mockResolvedValue ( { } ) ;
197200 const hawkPayload = {
198201 eventBody : {
@@ -204,14 +207,14 @@ describe('AlertingLeader', () => {
204207 const expectedEventPayload = { voice : { alerting : true , configured : true , clientType } } ;
205208
206209 expect . assertions ( 2 ) ;
207- alertingLeader . expose . on ( 'alertingLeaderChanged' , ( event ) => {
210+ alertingLeaderExposedApi . on ( 'alertingLeaderChanged' , ( event ) => {
208211 expect ( event ) . toMatchObject ( expectedEventPayload ) ;
209212 } ) ;
210213
211214 await alertingLeader [ 'subscribeToAlertingLeader' ] ( ) ;
212215 fakeClient . emit ( `notify:v2.users.${ userId } .alertingleader` , hawkPayload ) ;
213216
214- expect ( alertingLeader . expose . leaderStatus ) . toStrictEqual ( expectedEventPayload ) ;
217+ expect ( alertingLeaderExposedApi . getLeaderStatus ( ) ) . toStrictEqual ( expectedEventPayload ) ;
215218 } ) ;
216219
217220 it ( 'should not emit its own event if there is no eventBody' , async ( ) => {
@@ -221,12 +224,13 @@ describe('AlertingLeader', () => {
221224 fakeClient . config . userId = userId ;
222225 const alertingLeader = new AlertingLeaderExtension ( fakeClient , { } as IClientOptions ) ;
223226 alertingLeader [ 'connectionId' ] = connectionId ;
227+ const alertingLeaderExposedApi = alertingLeader . expose ;
224228 fakeClient . _notifications . _subscribeInternal = jest . fn ( ) . mockResolvedValue ( { } ) ;
225229 const hawkPayload = { } ;
226230
227231 expect . assertions ( 1 ) ;
228232 const eventSpy = jest . fn ( ) ;
229- alertingLeader . expose . on ( 'alertingLeaderChanged' , eventSpy ) ;
233+ alertingLeaderExposedApi . on ( 'alertingLeaderChanged' , eventSpy ) ;
230234
231235 await alertingLeader [ 'subscribeToAlertingLeader' ] ( ) ;
232236 fakeClient . emit ( `notify:v2.users.${ userId } .alertingleader` , hawkPayload ) ;
@@ -241,6 +245,7 @@ describe('AlertingLeader', () => {
241245 fakeClient . config . userId = userId ;
242246 const alertingLeader = new AlertingLeaderExtension ( fakeClient , { } as IClientOptions ) ;
243247 alertingLeader [ 'connectionId' ] = connectionId ;
248+ const alertingLeaderExposedApi = alertingLeader . expose ;
244249 fakeClient . _notifications . _subscribeInternal = jest . fn ( ) . mockResolvedValue ( { } ) ;
245250 const hawkPayload = {
246251 eventBody : {
@@ -254,7 +259,7 @@ describe('AlertingLeader', () => {
254259 const axiosMock = new AxiosMockAdapter ( axios ) ;
255260 axiosMock . onGet ( alertingLeaderUrl ) . reply ( 200 , { connectionId } ) ;
256261 const eventSpy = jest . fn ( ) ;
257- alertingLeader . expose . on ( 'alertingLeaderChanged' , eventSpy ) ;
262+ alertingLeaderExposedApi . on ( 'alertingLeaderChanged' , eventSpy ) ;
258263
259264 await alertingLeader [ 'subscribeToAlertingLeader' ] ( ) ;
260265 const getLeaderPromise = alertingLeader [ 'getAlertingLeader' ] ( ) ;
@@ -355,15 +360,16 @@ describe('AlertingLeader', () => {
355360 const clientOptions = { alertableInteractionTypes : [ AlertableInteractionTypes . voice ] } ;
356361 const alertingLeader = new AlertingLeaderExtension ( fakeClient , clientOptions as IClientOptions ) ;
357362 alertingLeader [ 'connectionId' ] = connectionId ;
363+ const alertingLeaderExposedApi = alertingLeader . expose ;
358364 const expectedPayload = { voice : { alerting : true , configured : true , clientType } } ;
359365
360366 expect . assertions ( 2 ) ;
361- alertingLeader . expose . on ( 'alertingLeaderChanged' , ( event ) => {
367+ alertingLeaderExposedApi . on ( 'alertingLeaderChanged' , ( event ) => {
362368 expect ( event ) . toStrictEqual ( expectedPayload ) ;
363369 } ) ;
364370 await alertingLeader [ 'getAlertingLeader' ] ( ) ;
365371
366- expect ( alertingLeader . expose . leaderStatus ) . toMatchObject ( expectedPayload ) ;
372+ expect ( alertingLeaderExposedApi . getLeaderStatus ( ) ) . toMatchObject ( expectedPayload ) ;
367373 axiosMock . restore ( ) ;
368374 } ) ;
369375
@@ -376,15 +382,16 @@ describe('AlertingLeader', () => {
376382 const clientOptions = { alertableInteractionTypes : [ AlertableInteractionTypes . voice ] } ;
377383 const alertingLeader = new AlertingLeaderExtension ( fakeClient , clientOptions as IClientOptions ) ;
378384 alertingLeader [ 'connectionId' ] = connectionId ;
385+ const alertingLeaderExposedApi = alertingLeader . expose ;
379386 const expectedPayload = { voice : { alerting : false , configured : true } } ;
380387
381388 expect . assertions ( 2 ) ;
382- alertingLeader . expose . on ( 'alertingLeaderChanged' , ( event ) => {
389+ alertingLeaderExposedApi . on ( 'alertingLeaderChanged' , ( event ) => {
383390 expect ( event ) . toStrictEqual ( expectedPayload ) ;
384391 } ) ;
385392 await alertingLeader [ 'getAlertingLeader' ] ( ) ;
386393
387- expect ( alertingLeader . expose . leaderStatus ) . toMatchObject ( expectedPayload ) ;
394+ expect ( alertingLeaderExposedApi . getLeaderStatus ( ) ) . toMatchObject ( expectedPayload ) ;
388395 axiosMock . restore ( ) ;
389396 } ) ;
390397
@@ -421,8 +428,9 @@ describe('AlertingLeader', () => {
421428 const clientOptions = { alertableInteractionTypes : [ AlertableInteractionTypes . voice ] } ;
422429 const alertingLeader = new AlertingLeaderExtension ( fakeClient , clientOptions as IClientOptions ) ;
423430 alertingLeader [ 'connectionId' ] = connectionId ;
431+ const alertingLeaderExposedApi = alertingLeader . expose ;
424432
425- alertingLeader . expose . claimAlertingLeader ( ) ;
433+ alertingLeaderExposedApi . claimAlertingLeader ( ) ;
426434
427435 expect ( httpSpy . mock . calls [ 0 ] [ 0 ] ) . toBe ( alertingLeaderPath ) ;
428436 expect ( httpSpy . mock . calls [ 0 ] [ 1 ] ) . toMatchObject ( { data : { connectionId : connectionId } } ) ;
@@ -437,9 +445,10 @@ describe('AlertingLeader', () => {
437445 fakeClient . http . requestApi = httpSpy ;
438446 const alertingLeader = new AlertingLeaderExtension ( fakeClient , { } as IClientOptions ) ;
439447 alertingLeader [ 'connectionId' ] = connectionId ;
448+ const alertingLeaderExposedApi = alertingLeader . expose ;
440449
441450 try {
442- await alertingLeader . expose . claimAlertingLeader ( ) ;
451+ await alertingLeaderExposedApi . claimAlertingLeader ( ) ;
443452 } catch ( err ) {
444453 expect ( err ) . toBeInstanceOf ( StreamingClientError ) ;
445454 expect ( ( err as any ) [ 'type' ] ) . toBe ( StreamingClientErrorTypes . generic ) ;
@@ -459,9 +468,10 @@ describe('AlertingLeader', () => {
459468 const clientOptions = { alertableInteractionTypes : [ AlertableInteractionTypes . voice ] } ;
460469 const alertingLeader = new AlertingLeaderExtension ( fakeClient , clientOptions as IClientOptions ) ;
461470 alertingLeader [ 'connectionId' ] = connectionId ;
471+ const alertingLeaderExposedApi = alertingLeader . expose ;
462472
463473 try {
464- await alertingLeader . expose . claimAlertingLeader ( ) ;
474+ await alertingLeaderExposedApi . claimAlertingLeader ( ) ;
465475 } catch ( err ) {
466476 expect ( err ) . toBeInstanceOf ( StreamingClientError ) ;
467477 expect ( ( err as any ) [ 'type' ] ) . toBe ( StreamingClientErrorTypes . generic ) ;
0 commit comments