@@ -22,9 +22,17 @@ import { Item } from '../core/shared/item.model';
2222import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service' ;
2323import { ThemeService } from '../shared/theme-support/theme.service' ;
2424import { getMockThemeService } from '../shared/mocks/theme-service.mock' ;
25+ import { Store , StoreModule } from '@ngrx/store' ;
26+ import { AppState , storeModuleConfig } from '../app.reducer' ;
27+ import { authReducer } from '../core/auth/auth.reducer' ;
28+ import { provideMockStore } from '@ngrx/store/testing' ;
29+ import { AuthTokenInfo } from '../core/auth/models/auth-token-info.model' ;
30+ import { EPersonMock } from '../shared/testing/eperson.mock' ;
2531
2632let comp : NavbarComponent ;
2733let fixture : ComponentFixture < NavbarComponent > ;
34+ let store : Store < AppState > ;
35+ let initialState : any ;
2836
2937const authorizationService = jasmine . createSpyObj ( 'authorizationService' , {
3038 isAuthorized : observableOf ( true )
@@ -83,10 +91,24 @@ describe('NavbarComponent', () => {
8391 }
8492 ) ,
8593 ] ;
94+ initialState = {
95+ core : {
96+ auth : {
97+ authenticated : true ,
98+ loaded : true ,
99+ blocking : false ,
100+ loading : false ,
101+ authToken : new AuthTokenInfo ( 'test_token' ) ,
102+ userId : EPersonMock . id ,
103+ authMethods : [ ]
104+ }
105+ }
106+ } ;
86107
87108 TestBed . configureTestingModule ( {
88109 imports : [
89110 TranslateModule . forRoot ( ) ,
111+ StoreModule . forRoot ( { auth : authReducer } , storeModuleConfig ) ,
90112 NoopAnimationsModule ,
91113 ReactiveFormsModule ,
92114 RouterTestingModule ] ,
@@ -99,6 +121,7 @@ describe('NavbarComponent', () => {
99121 { provide : ActivatedRoute , useValue : routeStub } ,
100122 { provide : BrowseService , useValue : { getBrowseDefinitions : createSuccessfulRemoteDataObject$ ( buildPaginatedList ( undefined , browseDefinitions ) ) } } ,
101123 { provide : AuthorizationDataService , useValue : authorizationService } ,
124+ provideMockStore ( { initialState } ) ,
102125 ] ,
103126 schemas : [ NO_ERRORS_SCHEMA ]
104127 } )
@@ -107,7 +130,7 @@ describe('NavbarComponent', () => {
107130
108131 // synchronous beforeEach
109132 beforeEach ( ( ) => {
110-
133+ store = TestBed . inject ( Store ) ;
111134 fixture = TestBed . createComponent ( NavbarComponent ) ;
112135
113136 comp = fixture . componentInstance ;
0 commit comments