@@ -5,7 +5,10 @@ import { AppComponent } from './app.component';
55import { AuthService } from '../../../auth0-angular/src/lib/auth.service' ;
66import { BehaviorSubject , of , ReplaySubject } from 'rxjs' ;
77import { ReactiveFormsModule } from '@angular/forms' ;
8- import { HttpClientModule } from '@angular/common/http' ;
8+ import {
9+ provideHttpClient ,
10+ withInterceptorsFromDi ,
11+ } from '@angular/common/http' ;
912import { expect } from '@jest/globals' ;
1013
1114describe ( 'AppComponent' , ( ) => {
@@ -29,13 +32,14 @@ describe('AppComponent', () => {
2932 } as any ;
3033
3134 TestBed . configureTestingModule ( {
32- imports : [ RouterTestingModule , ReactiveFormsModule , HttpClientModule ] ,
3335 declarations : [ AppComponent ] ,
36+ imports : [ RouterTestingModule , ReactiveFormsModule ] ,
3437 providers : [
3538 {
3639 provide : AuthService ,
3740 useValue : authMock ,
3841 } ,
42+ provideHttpClient ( withInterceptorsFromDi ( ) ) ,
3943 ] ,
4044 } ) . compileComponents ( ) ;
4145
@@ -84,7 +88,8 @@ describe('AppComponent', () => {
8488 describe ( 'when user is authenticated' , ( ) => {
8589 beforeEach ( ( ) => {
8690 const loading = authMock . isLoading$ as BehaviorSubject < boolean > ;
87- const authenticated = authMock . isAuthenticated$ as BehaviorSubject < boolean > ;
91+ const authenticated =
92+ authMock . isAuthenticated$ as BehaviorSubject < boolean > ;
8893 const user = authMock . user$ as BehaviorSubject < any > ;
8994
9095 loading . next ( false ) ;
@@ -189,9 +194,9 @@ describe('AppComponent', () => {
189194 ) ;
190195 const form = component . accessTokenOptionsForm . controls ;
191196 form [ 'usePopup' ] . setValue ( false ) ;
192- ( ( authMock . getAccessTokenSilently as unknown ) as jest . SpyInstance ) . mockReturnValue (
193- of ( 'access token silently' )
194- ) ;
197+ (
198+ authMock . getAccessTokenSilently as unknown as jest . SpyInstance
199+ ) . mockReturnValue ( of ( 'access token silently' ) ) ;
195200
196201 const btnRefresh = divToken . querySelector ( 'button' ) ;
197202 btnRefresh ?. click ( ) ;
@@ -212,9 +217,9 @@ describe('AppComponent', () => {
212217 const form = component . accessTokenOptionsForm . controls ;
213218 form [ 'usePopup' ] . setValue ( false ) ;
214219 form [ 'ignoreCache' ] . setValue ( false ) ;
215- ( ( authMock . getAccessTokenSilently as unknown ) as jest . SpyInstance ) . mockReturnValue (
216- of ( 'access token silently' )
217- ) ;
220+ (
221+ authMock . getAccessTokenSilently as unknown as jest . SpyInstance
222+ ) . mockReturnValue ( of ( 'access token silently' ) ) ;
218223
219224 const btnRefresh = divToken . querySelector ( 'button' ) ;
220225 btnRefresh ?. click ( ) ;
@@ -235,9 +240,9 @@ describe('AppComponent', () => {
235240 const form = component . accessTokenOptionsForm . controls ;
236241 form [ 'usePopup' ] . setValue ( false ) ;
237242 form [ 'ignoreCache' ] . setValue ( true ) ;
238- ( ( authMock . getAccessTokenSilently as unknown ) as jest . SpyInstance ) . mockReturnValue (
239- of ( 'access token silently' )
240- ) ;
243+ (
244+ authMock . getAccessTokenSilently as unknown as jest . SpyInstance
245+ ) . mockReturnValue ( of ( 'access token silently' ) ) ;
241246
242247 const btnRefresh = divToken . querySelector ( 'button' ) ;
243248 btnRefresh ?. click ( ) ;
@@ -257,9 +262,9 @@ describe('AppComponent', () => {
257262 ) ;
258263 const form = component . accessTokenOptionsForm . controls ;
259264 form [ 'usePopup' ] . setValue ( true ) ;
260- ( ( authMock . getAccessTokenWithPopup as unknown ) as jest . SpyInstance ) . mockReturnValue (
261- of ( 'access token popup' )
262- ) ;
265+ (
266+ authMock . getAccessTokenWithPopup as unknown as jest . SpyInstance
267+ ) . mockReturnValue ( of ( 'access token popup' ) ) ;
263268
264269 const btnRefresh = divToken . querySelector ( 'button' ) ;
265270 btnRefresh ?. click ( ) ;
@@ -274,7 +279,8 @@ describe('AppComponent', () => {
274279 describe ( 'when user is not authenticated' , ( ) => {
275280 beforeEach ( ( ) => {
276281 const loading = authMock . isLoading$ as BehaviorSubject < boolean > ;
277- const authenticated = authMock . isAuthenticated$ as BehaviorSubject < boolean > ;
282+ const authenticated =
283+ authMock . isAuthenticated$ as BehaviorSubject < boolean > ;
278284
279285 loading . next ( false ) ;
280286 authenticated . next ( false ) ;
0 commit comments