@@ -5,11 +5,15 @@ import { of } from 'rxjs';
55import { LoginComponent } from './login.component' ;
66import { Router } from '@angular/router' ;
77import { FeatureToggleCookiesService } from '../shared/feature-toggles/feature-toggle-cookies/feature-toggle-cookies.service' ;
8+ import { LoginService } from './services/login.service' ;
9+ import { HttpClientTestingModule } from '@angular/common/http/testing' ;
10+ import { SocialAuthService } from 'angularx-social-login' ;
811
912describe ( 'LoginComponent' , ( ) => {
1013 let component : LoginComponent ;
1114 let fixture : ComponentFixture < LoginComponent > ;
1215 let azureAdB2CService : AzureAdB2CService ;
16+ let loginService : LoginService ;
1317 let featureToggleCookiesService : FeatureToggleCookiesService ;
1418
1519 const azureAdB2CServiceStub = {
@@ -23,29 +27,46 @@ describe('LoginComponent', () => {
2327 }
2428 } ;
2529
30+ const loginServiceStub = {
31+ isLogin ( ) {
32+ return true ;
33+ } ,
34+ signIn ( ) {
35+ return of ( ) ;
36+ } ,
37+ setCookies ( ) {
38+ }
39+ } ;
40+
2641 const featureToggleCookiesServiceStub = {
2742 setCookies ( ) {
2843 return null ;
2944 }
3045 } ;
3146
47+ const socialAuthServiceStub = jasmine . createSpyObj ( 'SocialAuthService' , [ 'authState' ] ) ;
3248 beforeEach ( waitForAsync ( ( ) => {
3349 TestBed . configureTestingModule ( {
34- imports : [ RouterTestingModule ] ,
50+ imports : [ RouterTestingModule , HttpClientTestingModule ] ,
3551 declarations : [ LoginComponent ] ,
3652 providers : [
3753 { providers : AzureAdB2CService , useValue : azureAdB2CServiceStub } ,
38- { providers : FeatureToggleCookiesService , useValue : featureToggleCookiesServiceStub }
54+ { providers : FeatureToggleCookiesService , useValue : featureToggleCookiesServiceStub } ,
55+ { providers : LoginService , useValue : loginServiceStub } ,
56+ { provide : SocialAuthService , useValue : socialAuthServiceStub }
3957 ]
4058 } )
4159 . compileComponents ( ) ;
4260 } ) ) ;
4361
4462 beforeEach ( ( ) => {
63+ socialAuthServiceStub . authState = of ( null ) ;
4564 fixture = TestBed . createComponent ( LoginComponent ) ;
4665 component = fixture . componentInstance ;
66+ component . isDevelopment = false ;
4767 fixture . detectChanges ( ) ;
4868 azureAdB2CService = TestBed . inject ( AzureAdB2CService ) ;
69+ loginService = TestBed . inject ( LoginService ) ;
4970 featureToggleCookiesService = TestBed . inject ( FeatureToggleCookiesService ) ;
5071 } ) ;
5172
0 commit comments