Tests for default layout component

This commit is contained in:
ziajka 2019-01-23 15:31:03 +01:00
parent 6853901341
commit dc22510d30
2 changed files with 38 additions and 5 deletions

View File

@ -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<DefaultLayoutComponent>;
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();
});
});

View File

@ -12,7 +12,7 @@ export class DefaultLayoutComponent implements OnInit {
constructor(
private electronService: ElectronService
) { }
) {}
ngOnInit() {
this.isInstalledSoftwareAvailable = this.electronService.isElectronApp;