diff --git a/bcmi/src/app/app.component.spec.ts b/bcmi/src/app/app.component.spec.ts index 2f09110..48d69bd 100644 --- a/bcmi/src/app/app.component.spec.ts +++ b/bcmi/src/app/app.component.spec.ts @@ -9,6 +9,8 @@ import { AppComponent } from './app.component'; import { SafeHtmlPipe } from '@pipes/safe-html.pipe'; import { Apollo } from 'apollo-angular'; import { ContentService } from './services/content-service'; +import { HeaderComponent } from './header/header.component'; +import { FooterComponent } from './footer/footer.component'; describe('AppComponent', () => { beforeEach(waitForAsync(() => { @@ -21,6 +23,8 @@ describe('AppComponent', () => { ContentService ], declarations: [ + HeaderComponent, + FooterComponent, AppComponent, SafeHtmlPipe ], diff --git a/bcmi/src/app/app.component.ts b/bcmi/src/app/app.component.ts index ee6d676..80188b0 100644 --- a/bcmi/src/app/app.component.ts +++ b/bcmi/src/app/app.component.ts @@ -44,8 +44,10 @@ export class AppComponent implements OnInit, AfterViewInit { private modalService: NgbModal, private configService: ConfigService, private router: Router) { - this.footer = configService.globalContent.footer?.data.attributes; - this.navigation = configService.globalContent.navigations?.data; + if(configService.globalContent){ + this.footer = configService.globalContent.footer?.data.attributes; + this.navigation = configService.globalContent.navigations?.data; + } this.router.events.subscribe((event: Event) => { switch (true) { case event instanceof NavigationStart: { diff --git a/bcmi/src/app/app.module.ts b/bcmi/src/app/app.module.ts index b3e50d8..d5911ad 100644 --- a/bcmi/src/app/app.module.ts +++ b/bcmi/src/app/app.module.ts @@ -48,10 +48,10 @@ export function initConfig(configService: ConfigService) { @NgModule({ declarations: [ - AppComponent, - HomeComponent, HeaderComponent, FooterComponent, + AppComponent, + HomeComponent, LegislationComponent, ComplianceOversightComponent, ContactComponent, diff --git a/bcmi/src/app/footer/footer.component.spec.ts b/bcmi/src/app/footer/footer.component.spec.ts deleted file mode 100644 index 0dc0ed9..0000000 --- a/bcmi/src/app/footer/footer.component.spec.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { ProjectService } from '@services/project.service'; -import { ConfigService } from '@services/config.service'; -import { Api } from '@services/api'; -import { HttpClientModule } from '@angular/common/http'; -import { FooterComponent } from '../footer/footer.component'; -import { Project } from '@models/project'; -import { ContentService } from '@app/services/content-service'; -import { Apollo } from 'apollo-angular'; - -window.scrollTo = jest.fn(); - -describe('FooterComponent', () => { - let fixture: ComponentFixture; - let ProjectServiceStub; - - beforeEach(waitForAsync(() => { - // stub project service - ProjectServiceStub = { - getAll: jest.fn().mockReturnValue({ - subscribe: function(fn) { - fn(Array()); - } - }) - }; - TestBed.configureTestingModule({ - declarations: [FooterComponent], - providers: [{ provide: ProjectService, useValue: ProjectServiceStub }, Api, ConfigService, ContentService, Apollo], - imports: [RouterTestingModule, HttpClientModule] - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FooterComponent); - fixture.detectChanges(); - }); - describe('ngOnInit()', () => { - it('should call projectService.getAll()', () => { - expect(ProjectServiceStub.getAll).toHaveBeenCalled(); - }); - }); -}); diff --git a/bcmi/src/app/header/header.component.spec.ts b/bcmi/src/app/header/header.component.spec.ts deleted file mode 100644 index 8d4c2b5..0000000 --- a/bcmi/src/app/header/header.component.spec.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { ProjectService } from '@services/project.service'; -import { ConfigService } from '@services/config.service'; -import { Api } from '@services/api'; -import { HttpClientModule } from '@angular/common/http'; -import { HeaderComponent } from '../header/header.component'; -import { Project } from '@models/project'; -import { ContentService } from '@app/services/content-service'; -import { Apollo } from 'apollo-angular'; - -window.scrollTo = jest.fn(); - -describe('HeaderComponent', () => { - let fixture: ComponentFixture; - let ProjectServiceStub; - - beforeEach(waitForAsync(() => { - // stub project service - ProjectServiceStub = { - getAll: jest.fn().mockReturnValue({ - subscribe: function(fn) { - fn(Array()); - } - }) - }; - TestBed.configureTestingModule({ - declarations: [HeaderComponent], - providers: [{ provide: ProjectService, useValue: ProjectServiceStub }, Api, ConfigService, ContentService, Apollo], - imports: [RouterTestingModule, HttpClientModule] - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(HeaderComponent); - fixture.detectChanges(); - }); - describe('ngOnInit()', () => { - it('should call projectService.getAll()', () => { - expect(ProjectServiceStub.getAll).toHaveBeenCalled(); - }); - }); -});