@@ -2,12 +2,14 @@ import { TestBed } from "@angular/core/testing";
2
2
import {
3
3
AuthenticationResult ,
4
4
AuthError ,
5
+ InteractionStatus ,
5
6
InteractionType ,
6
7
Logger ,
7
8
PublicClientApplication ,
8
9
SilentRequest ,
9
10
} from "@azure/msal-browser" ;
10
11
import { MsalModule , MsalBroadcastService , MsalService } from "./public-api" ;
12
+ import { takeLast } from "rxjs/operators" ;
11
13
12
14
let authService : MsalService ;
13
15
let broadcastService : MsalBroadcastService ;
@@ -351,11 +353,14 @@ describe("MsalService", () => {
351
353
} ) ;
352
354
353
355
describe ( "handleRedirectObservable" , ( ) => {
354
- it ( "success" , ( done ) => {
356
+ it ( "success and resets inProgress event to none " , ( done ) => {
355
357
const sampleAccessToken = {
356
358
accessToken : "123abc" ,
357
359
} ;
358
360
361
+ //@ts -ignore
362
+ broadcastService . _inProgress . next ( InteractionStatus . Startup ) ;
363
+
359
364
spyOn ( PublicClientApplication . prototype , "initialize" ) . and . returnValue (
360
365
Promise . resolve ( )
361
366
) ;
@@ -380,13 +385,19 @@ describe("MsalService", () => {
380
385
expect (
381
386
PublicClientApplication . prototype . handleRedirectPromise
382
387
) . toHaveBeenCalled ( ) ;
388
+ broadcastService . inProgress$ . subscribe ( ( result ) => {
389
+ expect ( result ) . toBe ( InteractionStatus . None ) ;
390
+ } ) ;
383
391
done ( ) ;
384
392
} ) ;
385
393
} ) ;
386
394
387
- it ( "failure" , ( done ) => {
395
+ it ( "failure and also resets inProgress event to none " , ( done ) => {
388
396
const sampleError = new AuthError ( "123" , "message" ) ;
389
397
398
+ //@ts -ignore
399
+ broadcastService . _inProgress . next ( InteractionStatus . Startup ) ;
400
+
390
401
spyOn ( PublicClientApplication . prototype , "initialize" ) . and . returnValue (
391
402
Promise . resolve ( )
392
403
) ;
@@ -409,6 +420,10 @@ describe("MsalService", () => {
409
420
expect (
410
421
PublicClientApplication . prototype . handleRedirectPromise
411
422
) . toHaveBeenCalled ( ) ;
423
+ broadcastService . inProgress$ . pipe ( takeLast ( 1 ) ) . subscribe ( ( result ) => {
424
+ console . log ( "failure result" , result ) ;
425
+ expect ( result ) . toBe ( InteractionStatus . None ) ;
426
+ } ) ;
412
427
done ( ) ;
413
428
} ,
414
429
} ) ;
0 commit comments