1- // ... test imports
2- import { CommonModule } from '@angular/common' ;
3- import {
4- CUSTOM_ELEMENTS_SCHEMA ,
5- DebugElement ,
6- } from '@angular/core' ;
71import {
82 ComponentFixture ,
93 fakeAsync ,
@@ -13,28 +7,19 @@ import {
137} from '@angular/core/testing' ;
148import { By } from '@angular/platform-browser' ;
159import { ActivatedRoute } from '@angular/router' ;
16- import { StoreModule } from '@ngrx/store' ;
17- import {
18- TranslateLoader ,
19- TranslateModule ,
20- } from '@ngx-translate/core' ;
10+ import { TranslateModule } from '@ngx-translate/core' ;
2111import { of } from 'rxjs' ;
22- import { environment } from 'src/environments/environment' ;
2312
24- import { storeModuleConfig } from '../app.reducer' ;
13+ import { APP_CONFIG } from '../../config/app-config.interface' ;
14+ import { environment } from '../../environments/environment.test' ;
2515import { NotifyInfoService } from '../core/coar-notify/notify-info/notify-info.service' ;
2616import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service' ;
27- import { TranslateLoaderMock } from '../shared/mocks/translate-loader.mock' ;
2817import { ActivatedRouteStub } from '../shared/testing/active-router.stub' ;
2918import { AuthorizationDataServiceStub } from '../shared/testing/authorization-service.stub' ;
30- // Load the implementations that should be tested
3119import { FooterComponent } from './footer.component' ;
3220
3321let comp : FooterComponent ;
34- let compAny : any ;
3522let fixture : ComponentFixture < FooterComponent > ;
36- let de : DebugElement ;
37- let el : HTMLElement ;
3823
3924let notifyInfoService = {
4025 isCoarConfigEnabled : ( ) => of ( true ) ,
@@ -43,30 +28,23 @@ let notifyInfoService = {
4328describe ( 'Footer component' , ( ) => {
4429 beforeEach ( waitForAsync ( ( ) => {
4530 return TestBed . configureTestingModule ( {
46- imports : [ CommonModule , StoreModule . forRoot ( { } , storeModuleConfig ) , TranslateModule . forRoot ( {
47- loader : {
48- provide : TranslateLoader ,
49- useClass : TranslateLoaderMock ,
50- } ,
51- } ) , FooterComponent ] ,
31+ imports : [
32+ TranslateModule . forRoot ( ) ,
33+ ] ,
5234 providers : [
5335 FooterComponent ,
5436 { provide : AuthorizationDataService , useClass : AuthorizationDataServiceStub } ,
5537 { provide : NotifyInfoService , useValue : notifyInfoService } ,
5638 { provide : ActivatedRoute , useValue : new ActivatedRouteStub ( ) } ,
39+ { provide : APP_CONFIG , useValue : environment } ,
5740 ] ,
58- schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
5941 } ) ;
6042 } ) ) ;
6143
6244 // synchronous beforeEach
6345 beforeEach ( ( ) => {
6446 fixture = TestBed . createComponent ( FooterComponent ) ;
6547 comp = fixture . componentInstance ;
66- compAny = comp as any ;
67- // query for the title <p> by CSS element selector
68- de = fixture . debugElement . query ( By . css ( 'p' ) ) ;
69- el = de . nativeElement ;
7048 } ) ;
7149
7250 it ( 'should create footer' , inject ( [ FooterComponent ] , ( app : FooterComponent ) => {
@@ -76,23 +54,25 @@ describe('Footer component', () => {
7654
7755
7856 it ( 'should set showPrivacyPolicy to the value of environment.info.enablePrivacyStatement' , ( ) => {
57+ comp . ngOnInit ( ) ;
7958 expect ( comp . showPrivacyPolicy ) . toBe ( environment . info . enablePrivacyStatement ) ;
8059 } ) ;
8160
8261 it ( 'should set showEndUserAgreement to the value of environment.info.enableEndUserAgreement' , ( ) => {
62+ comp . ngOnInit ( ) ;
8363 expect ( comp . showEndUserAgreement ) . toBe ( environment . info . enableEndUserAgreement ) ;
8464 } ) ;
8565
8666 describe ( 'showCookieSettings' , ( ) => {
8767 it ( 'should call cookies.showSettings() if cookies is defined' , ( ) => {
8868 const cookies = jasmine . createSpyObj ( 'cookies' , [ 'showSettings' ] ) ;
89- compAny . cookies = cookies ;
69+ comp . cookies = cookies ;
9070 comp . showCookieSettings ( ) ;
9171 expect ( cookies . showSettings ) . toHaveBeenCalled ( ) ;
9272 } ) ;
9373
9474 it ( 'should not call cookies.showSettings() if cookies is undefined' , ( ) => {
95- compAny . cookies = undefined ;
75+ comp . cookies = undefined ;
9676 expect ( ( ) => comp . showCookieSettings ( ) ) . not . toThrow ( ) ;
9777 } ) ;
9878
@@ -107,9 +87,7 @@ describe('Footer component', () => {
10787 fixture . detectChanges ( ) ;
10888 } ) ;
10989
110- it ( 'should set coarLdnEnabled based on notifyInfoService' , ( ) => {
111- expect ( comp . coarLdnEnabled ) . toBeTruthy ( ) ;
112- // Check if COAR Notify section is rendered
90+ it ( 'should render COAR notify support link' , ( ) => {
11391 const notifySection = fixture . debugElement . query ( By . css ( '.notify-enabled' ) ) ;
11492 expect ( notifySection ) . toBeTruthy ( ) ;
11593 } ) ;
0 commit comments