From dc22510d30227e36d78d0342af95655adf040e86 Mon Sep 17 00:00:00 2001 From: ziajka Date: Wed, 23 Jan 2019 15:31:03 +0100 Subject: [PATCH] Tests for default layout component --- .../default-layout.component.spec.ts | 41 +++++++++++++++++-- .../default-layout.component.ts | 2 +- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/app/layouts/default-layout/default-layout.component.spec.ts b/src/app/layouts/default-layout/default-layout.component.spec.ts index bd44ca4e..47f00002 100644 --- a/src/app/layouts/default-layout/default-layout.component.spec.ts +++ b/src/app/layouts/default-layout/default-layout.component.spec.ts @@ -1,14 +1,35 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { DefaultLayoutComponent } from './default-layout.component'; +import { ElectronService } from 'ngx-electron'; +import { MatIconModule, MatMenuModule, MatToolbarModule, MatProgressSpinnerModule } from '@angular/material'; +import { RouterTestingModule } from '@angular/router/testing'; +import { ProgressComponent } from '../../common/progress/progress.component'; +import { ProgressService } from '../../common/progress/progress.service'; + + +class ElectronServiceMock { + public isElectronApp: boolean; +} describe('DefaultLayoutComponent', () => { let component: DefaultLayoutComponent; let fixture: ComponentFixture; + let electronServiceMock: ElectronServiceMock; beforeEach(async(() => { + electronServiceMock = new ElectronServiceMock(); + TestBed.configureTestingModule({ - declarations: [DefaultLayoutComponent] + declarations: [DefaultLayoutComponent, ProgressComponent], + imports: [MatIconModule, MatMenuModule, MatToolbarModule, RouterTestingModule, MatProgressSpinnerModule], + providers: [ + { + provide: ElectronService, + useValue: electronServiceMock + }, + ProgressService + ] }).compileComponents(); })); @@ -18,7 +39,19 @@ describe('DefaultLayoutComponent', () => { fixture.detectChanges(); }); - // it('should create', () => { - // expect(component).toBeTruthy(); - // }); + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should installed software be available', () => { + electronServiceMock.isElectronApp = true; + component.ngOnInit(); + expect(component.isInstalledSoftwareAvailable).toBeTruthy(); + }); + + it('should installed software be not available', () => { + electronServiceMock.isElectronApp = false; + component.ngOnInit(); + expect(component.isInstalledSoftwareAvailable).toBeFalsy(); + }); }); diff --git a/src/app/layouts/default-layout/default-layout.component.ts b/src/app/layouts/default-layout/default-layout.component.ts index fb974ee4..162f83c6 100644 --- a/src/app/layouts/default-layout/default-layout.component.ts +++ b/src/app/layouts/default-layout/default-layout.component.ts @@ -12,7 +12,7 @@ export class DefaultLayoutComponent implements OnInit { constructor( private electronService: ElectronService - ) { } + ) {} ngOnInit() { this.isInstalledSoftwareAvailable = this.electronService.isElectronApp;